var weatherUrl = "http://localhost"
var _fcTypeNum=0;
L.DomUtil.setTransform || (L.DomUtil.setTransform = function(t, n, e) {
  n = n || new L.Point(0, 0);
  t.style[L.DomUtil.TRANSFORM] = (L.Browser.ie3d ? "translate(" + n.x + "px," + n.y + "px)" : "translate3d(" + n.x + "px," + n.y + "px,0)") + (e ? " scale(" + e + ")" : "")
}), L.CanvasLayer = (L.Layer || L.Class).extend({
  initialize: function(t) {
    this._map = null, this._canvas = null, this._frame = null, this._delegate = null, L.setOptions(this, t)
  },
  delegate: function(t) {
    return this._delegate = t, this
  },
  needRedraw: function() {
    return this._frame || (this._frame = L.Util.requestAnimFrame(this.drawLayer, this)), this
  },
  _onLayerDidResize: function(t) {
    this._canvas.width = t.newSize.x, this._canvas.height = t.newSize.y
  },
  _onLayerDidMove: function() {
    var t = this._map.containerPointToLayerPoint([0, 0]);
    L.DomUtil.setPosition(this._canvas, t), this.drawLayer()
  },
  getEvents: function() {
    var t = {
      resize: this._onLayerDidResize,
      moveend: this._onLayerDidMove
    };
    return this._map.options.zoomAnimation && L.Browser.any3d && (t.zoomanim = this._animateZoom), t
  },
  onAdd: function(t) {
    this._map = t, this._canvas = L.DomUtil.create("canvas", "leaflet-layer"), this.tiles = {};
    var n = this._map.getSize();
    this._canvas.width = n.x, this._canvas.height = n.y;
    n = this._map.options.zoomAnimation && L.Browser.any3d;
    L.DomUtil.addClass(this._canvas, "leaflet-zoom-" + (n ? "animated" : "hide")), t._panes.overlayPane.appendChild(this._canvas), t.on(this.getEvents(), this);
    t = this._delegate || this;
    t.onLayerDidMount && t.onLayerDidMount(), this.needRedraw();
    var e = this;
    setTimeout(function() {
      e._onLayerDidMove()
    }, 0)
  },
  onRemove: function(t) {
    var n = this._delegate || this;
    n.onLayerWillUnmount && n.onLayerWillUnmount(), t.getPanes().overlayPane.removeChild(this._canvas), t.off(this.getEvents(), this), this._canvas = null
  },
  addTo: function(t) {
    return t.addLayer(this), this
  },
  LatLonToMercator: function(t) {
    return {
      x: 6378137 * t.lng * Math.PI / 180,
      y: 6378137 * Math.log(Math.tan((90 + t.lat) * Math.PI / 360))
    }
  },
  drawLayer: function() {
    var t = this._map.getSize(),
        n = this._map.getBounds(),
        e = this._map.getZoom(),
        i = this.LatLonToMercator(this._map.getCenter()),
        r = this.LatLonToMercator(this._map.containerPointToLatLng(this._map.getSize())),
        o = this._delegate || this;
    o.onDrawLayer && o.onDrawLayer({
      layer: this,
      canvas: this._canvas,
      bounds: n,
      size: t,
      zoom: e,
      center: i,
      corner: r
    }), this._frame = null
  },
  _setTransform: function(t, n, e) {
    n = n || new L.Point(0, 0);
    t.style[L.DomUtil.TRANSFORM] = (L.Browser.ie3d ? "translate(" + n.x + "px," + n.y + "px)" : "translate3d(" + n.x + "px," + n.y + "px,0)") + (e ? " scale(" + e + ")" : "")
  },
  _animateZoom: function(t) {
    var n = this._map.getZoomScale(t.zoom),
        t = L.Layer ? this._map._latLngToNewLayerPoint(this._map.getBounds().getNorthWest(), t.zoom, t.center) : this._map._getCenterOffset(t.center)._multiplyBy(-n).subtract(this._map._getMapPanePos());
    L.DomUtil.setTransform(this._canvas, t, n)
  }
}), L.canvasLayer = function() {
  return new L.CanvasLayer
}, L.Control.Velocity = L.Control.extend({
  options: {
    position: "bottomleft",
    emptyString: "",
    angleConvention: "meteoCCW",
    speedUnit: "m/s"
  },
  onAdd: function(t) {
    return this._currentPoint = document.getElementById("currentPoint"), this._mapBox = t._container, this._container = L.DomUtil.create("div", "leaflet-control-velocity"), this._div = document.getElementById("wind-value"), L.DomEvent.disableClickPropagation(this._div), this._div.innerHTML = this.options.emptyString, this._div.style.display = "block", t.on("mousemove", this._onMouseMove, this), this._container
  },
  onRemove: function(t) {
    document.getElementById("wind-value").style.display = "none", document.getElementById("wind-value").innerHTML = "", document.getElementById("currentPoint").style.display = "none", t.off("mousemove", this._onMouseMove, this)
  },
  vectorToSpeed: function(t, n, e) {
    n = Math.sqrt(Math.pow(t, 2) + Math.pow(n, 2));
    return "km/h" === e ? this.meterSec2kilometerHour(n) : "kt" === e ? this.meterSec2Knots(n) : n
  },
  rebuildWindDirection: function(t) {
    var n = "";
    return null == t ? n = "-" : t <= 22.5 || 337.5 <= t ? n = "北风" : 22.5 < t && t <= 67.5 ? n = "东北风" : 67.5 < t && t <= 112.5 ? n = "东风" : 112.5 < t && t <= 157.5 ? n = "东南风" : 157.5 < t && t <= 202.5 ? n = "南风" : 202.5 < t && t <= 247.5 ? n = "西南风" : 247.5 < t && t <= 292.5 ? n = "西风" : 292.5 < t && t <= 337.5 && (n = "西北风"), n
  },
  getWindLevel: function(t) {
    t = Number(t);
    return t < .2 ? "0级" : t < 1.5 ? "1级" : t < 3.3 ? "2级" : t < 5.4 ? "3级" : t < 7.9 ? "4级" : t < 10.7 ? "5级" : t < 13.8 ? "6级" : t < 17.1 ? "7级" : t < 20.7 ? "8级" : t < 24.4 ? "9级" : t < 28.4 ? "10级" : t < 32.6 ? "11级" : t < 36.9 ? "12级" : t < 41.4 ? "13级" : t < 46.1 ? "14级" : t < 50.9 ? "15级" : t < 56 ? "16级" : t < 61.2 ? "17级" : 61.3 < t ? "18级" : void 0
  },
  vectorToDegrees: function(t, n, e) {
    e.endsWith("CCW") && (n = 0 < n ? n = -n : Math.abs(n)), t = -t;
    var i = Math.sqrt(Math.pow(t, 2) + Math.pow(n, 2)),
        i = 180 * Math.atan2(t / i, n / i) / Math.PI + 180;
    return "bearingCW" !== e && "meteoCCW" !== e || 360 <= (i += 180) && (i -= 360), i
  },
  meterSec2Knots: function(t) {
    return t / .514
  },
  meterSec2kilometerHour: function(t) {
    return 3.6 * t
  },
  _onMouseMove: function(t) {
    var n = this,
        e = this.options.leafletVelocity._map.containerPointToLatLng(L.point(t.containerPoint.x, t.containerPoint.y)),
        i = this.options.leafletVelocity._windy.interpolatePoint(e.lng, e.lat),
        e = "";
    if(_fcTypeNum == 1){
      e = i && !isNaN(i[0]) && !isNaN(i[1]) && i[2] ? "<div style='display: " + (315 === n.vectorToDegrees(i[0], i[1], this.options.angleConvention) ? "none" : "block") + "'>" + n.rebuildWindDirection(n.vectorToDegrees(i[0], i[1], this.options.angleConvention)) + " " + n.getWindLevel(n.vectorToSpeed(i[0], i[1], this.options.speedUnit)) + " " + n.vectorToSpeed(i[0], i[1], this.options.speedUnit).toFixed(2) + this.options.speedUnit + "</div>" : this.options.emptyString, n._currentPoint && (t.containerPoint.x > n._mapBox.clientWidth - 200 ? n._currentPoint.style.left = n._mapBox.clientWidth + 132 + "px" : n._currentPoint.style.left = t.containerPoint.x + 632 + "px", t.containerPoint.y > n._mapBox.clientHeight - 30 ? n._currentPoint.style.top = n._mapBox.clientHeight - 180 + "px" : n._currentPoint.style.top = t.containerPoint.y +  "px", n._div.innerHTML = e,n._currentPoint.style.zIndex = 1001)
    }else if(_fcTypeNum == 2){
      var index = this._map.options.index
      if (index == 1) {
        e = i && !isNaN(i[0]) && !isNaN(i[1]) && i[2] ? 
        "<div style='display: " + (315 === n.vectorToDegrees(i[0], i[1], this.options.angleConvention) ? "none" : "block") + "'>" 
        + n.rebuildWindDirection(n.vectorToDegrees(i[0], i[1], this.options.angleConvention)) + " " 
        + n.getWindLevel(n.vectorToSpeed(i[0], i[1], this.options.speedUnit)) + " " 
        + n.vectorToSpeed(i[0], i[1], this.options.speedUnit).toFixed(2) + this.options.speedUnit + "</div>" 
      
        : this.options.emptyString, n._currentPoint && (
          t.containerPoint.x > n._mapBox.clientWidth - 200 ? n._currentPoint.style.left = n._mapBox.clientWidth + 1000 + "px" 
          : n._currentPoint.style.left = t.containerPoint.x + 1192 + "px",
          n._currentPoint.style.width = 160 + "px",
          t.containerPoint.y > n._mapBox.clientHeight - 30 ? n._currentPoint.style.top = n._mapBox.clientHeight - 180 + "px" 
          : n._currentPoint.style.top = t.containerPoint.y +  "px", n._div.innerHTML = e,n._currentPoint.style.zIndex = 1001)
      }else{
        e = i && !isNaN(i[0]) && !isNaN(i[1]) && i[2] ? 
        "<div style='display: " + (315 === n.vectorToDegrees(i[0], i[1], this.options.angleConvention) ? "none" : "block") + "'>" 
        + n.rebuildWindDirection(n.vectorToDegrees(i[0], i[1], this.options.angleConvention)) + " " 
        + n.getWindLevel(n.vectorToSpeed(i[0], i[1], this.options.speedUnit)) + " " 
        + n.vectorToSpeed(i[0], i[1], this.options.speedUnit).toFixed(2) + this.options.speedUnit + "</div>" 
        
        : this.options.emptyString, n._currentPoint && (
          t.containerPoint.x > n._mapBox.clientWidth - 200 ? n._currentPoint.style.left = n._mapBox.clientWidth - 162 + "px" 
          : n._currentPoint.style.left = t.containerPoint.x + 32 + "px", 
          t.containerPoint.y > n._mapBox.clientHeight - 30 ? n._currentPoint.style.top = n._mapBox.clientHeight - 180 + "px" 
          : n._currentPoint.style.top = t.containerPoint.y +  "px", n._div.innerHTML = e,n._currentPoint.style.zIndex = 1001)
      }
    }else{
      e = i && !isNaN(i[0]) && !isNaN(i[1]) && i[2] ? "<div style='display: " + (315 === n.vectorToDegrees(i[0], i[1], this.options.angleConvention) ? "none" : "block") + "'>" + n.rebuildWindDirection(n.vectorToDegrees(i[0], i[1], this.options.angleConvention)) + " " + n.getWindLevel(n.vectorToSpeed(i[0], i[1], this.options.speedUnit)) + " " + n.vectorToSpeed(i[0], i[1], this.options.speedUnit).toFixed(2) + this.options.speedUnit + "</div>" : this.options.emptyString, n._currentPoint && (t.containerPoint.x > n._mapBox.clientWidth - 200 ? n._currentPoint.style.left = n._mapBox.clientWidth - 132 + "px" : n._currentPoint.style.left = t.containerPoint.x + 32 + "px", t.containerPoint.y > n._mapBox.clientHeight - 30 ? n._currentPoint.style.top = n._mapBox.clientHeight - 180 + "px" : n._currentPoint.style.top = t.containerPoint.y +  "px", n._div.innerHTML = e,n._currentPoint.style.zIndex = 1001)
    }
    
  }
}), L.Map.mergeOptions({
  positionControl: !1
}), L.Map.addInitHook(function() {
  this.options.positionControl && (this.positionControl = new L.Control.MousePosition, this.addControl(this.positionControl))
}), L.control.velocity = function(t) {
  return new L.Control.Velocity(t)
}, L.VelocityLayer = (L.Layer || L.Class).extend({
  options: {
    windyShow: !1,
    displayValues: !0,
    displayOptions: {
      velocityType: "Velocity",
      position: "bottomleft",
      emptyString: ""
    },
    maxVelocity: 10,
    colorScale: null,
    data: null
  },
  _map: null,
  _canvasLayer: null,
  _windy: null,
  _context: null,
  _timer: 0,
  _mouseControl: null,
  _isWebGL: null,
  initialize: function(t) {
    L.setOptions(this, t)
  },
  onAdd: function(t) {
    this._canvasLayer = L.canvasLayer().delegate(this), this._canvasLayer.addTo(t), this._map = t, this.options.windyShow = !0
  },
  onRemove: function(t) {
    this._destroyWind(), this.options.windyShow = !1
  },
  setData: function(t, n) {
    if (this.options.data = t, this._windy) {
      if (this._isWebGL) {
        for (var e = t[0], i = t[1], r = Math.min.apply(null, e.data), o = Math.max.apply(null, e.data), a = Math.min.apply(null, i.data), s = Math.max.apply(null, i.data), u = e.header.max, l = e.header.min, h = [], c = 0; c < e.data.length; c++) {
          var f = Math.floor(255 * (e.data[c] - l) / (u - l));
          h.push(f);
          f = Math.floor(255 * (i.data[c] - l) / (u - l));
          h.push(f), h.push(0), h.push(255)
        }
        s = {
          width: e.header.nx,
          height: e.header.ny,
          uMin: r,
          uMax: o,
          vMin: a,
          vMax: s,
          image: h,
          full_extent: [e.header.lo1, e.header.lo2, e.header.la1, e.header.la2],
          dx: e.header.dx,
          dy: e.header.dy
        };
        this._windy.setWind(s)
      } else this._windy.setData(t);
      this._clearAndRestart()
    }
    this.fire("load")
  },
  setColorSM: function(t, n, e) {
    t = [t];
    this.options.colorScale = t, this.options.velocityScale = n, this.options.particleMultiplier = e, this._windy && (this._windy.setColorSM(t, n, e), this._clearAndRestart()), this.fire("load")
  },
  onDrawLayer: function(t, n) {
    var e = this;
    this._windy ? this.options.data && (this._windy && this._windy.stop(), this._context && !this._isWebGL && this._context.clearRect(0, 0, 3e3, 3e3), this._timer && clearTimeout(e._timer), this._timer = setTimeout(function() {
      e._startWindy()
    }, 500)) : this._initWindy(this)
  },
  _startWindy: function() {
    var t = this._map.getBounds(),
        n = this._map.getSize();
    this._windy.start([
      [0, 0],
      [n.x, n.y]
    ], n.x, n.y, [
      [t._southWest.lng, t._southWest.lat],
      [t._northEast.lng, t._northEast.lat]
    ])
  },
  _initWindy: function(t) {
    var n;
    this._isWebGL = !1, this._isWebGL ? (this._context = t._canvasLayer._canvas.getContext("webgl", {
      antialiasing: !1
    }), n = Object.assign({
      canvas: t._canvasLayer._canvas,
      ctx: this._context
    }, t.options), this._windy = new WindGL(this._context, n)) : (this._context = this._canvasLayer._canvas.getContext("2d"), n = Object.assign({
      canvas: t._canvasLayer._canvas,
      ctx: this._context
    }, t.options), this._windy = new Windy(n)), this._canvasLayer._canvas.classList.add("velocity-overlay"), this.onDrawLayer(), this._initMouseHandler()
  },
  _initMouseHandler: function() {
    var t;
    !this._mouseControl && this.options.displayValues && (((t = this.options.displayOptions || {}).leafletVelocity = this)._mouseControl = L.control.velocity(t).addTo(this._map))
  },
  _clearAndRestart: function() {//这里修改更新清理，修改之后，风场刷新更流畅   this._context && !this._isWebGL && this._context.clearRect(0, 0, 3e3, 3e3), this._windy && this._startWindy()
    this._context && !this._isWebGL , this._windy && this._startWindy()
  },
  _clearWind: function() {
    this._windy && this._windy.stop(), this._context && !this._isWebGL && this._context.clearRect(0, 0, 3e3, 3e3)
  },
  _destroyWind: function() {
    this._timer && clearTimeout(this._timer), this._windy && this._windy.stop(), this._context && !this._isWebGL && this._context.clearRect(0, 0, 3e3, 3e3), this._mouseControl && this._map.removeControl(this._mouseControl), this._mouseControl = null, this._windy = null, this._canvasLayer && this._map.removeLayer(this._canvasLayer)
  }
}), L.velocityLayer = function(t) {
  return new L.VelocityLayer(t)
};
var Windy = function(f) {
  function o(t, n, e, i, r, o) {
    var a = (u = 1 - t) * (s = 1 - n),
        s = t * s,
        u = u * n,
        t = t * n,
        n = e[0] * a + i[0] * s + r[0] * u + o[0] * t,
        t = e[1] * a + i[1] * s + r[1] * u + o[1] * t;
    return [n, t, Math.sqrt(n * n + t * t)]
  }

  function s(t) {
    var n, e, i = null,
        r = null,
        r = t[1],
        i = t[0];
    return r = r, n = (i = i).data, e = r.data, {
      header: i.header,
      data: function(t) {
        return [n[t], e[t]]
      },
      interpolate: o
    }
  }

  function a(e, r, t, n) {
    function o(t, n) {
      t = e[Math.round(t)];
      return t && t[Math.round(n)] || i
    }
    o.release = function() {
      e = []
    }, o.randomize = function(t) {
      for (var n, e, i = 0; n = Math.round(Math.floor(Math.random() * r.width) + r.x), e = Math.round(Math.floor(Math.random() * r.height) + r.y), null === o(n, e)[2] && i++ < 30;);
      return t.x = n, t.y = e, t
    }, n(r, o, t)
  }

  function u(t) {
    return t / 180 * Math.PI
  }

  function x(t) {
    return t / (Math.PI / 180)
  }

  function l(t) {
    return Math.log(Math.tan(t / 2 + Math.PI / 4))
  }

  function h(p, _, m, e) {
    var g = {},
        t = (m.south - m.north) * (m.west - m.east),
        v = P * Math.pow(t, .4),
        y = [],
        i = _.x,
        b = 6;

    function r(t) {
      for (var n, e, i, r, o, a, s = [], u = _.y; u <= _.yMax; u += b) {
        var l = (n = t, e = u, o = o = a = o = r = void 0, r = (i = m).east - i.west, o = i.width / x(r) * 360 / (2 * Math.PI), a = o / 2 * Math.log((1 + Math.sin(i.south)) / (1 - Math.sin(i.south))), o = (i.height + a - e) / o, o = 180 / Math.PI * (2 * Math.atan(Math.exp(o)) - Math.PI / 2), [x(i.west) + n / i.width * x(r), o]),
            h = l[0],
            c = l[1];
        if (isFinite(h)) {
          var f = p.interpolate(h, c);
          if (f) {
            a = g, e = h, n = c, i = t, r = u, o = v, l = m, h = void 0, h = (c = f)[0] * o, o = c[1] * o, l = B(a, e, n, i, r, l), c[0] = l[0] * h + l[2] * o, c[1] = l[1] * h + l[3] * o, f = c;
            for (var d = 1; d < b; d += 1) s[u + d] = s[u] = f
          }
        }
      }
      for (d = 1; d < b; d += 1) y[t + d] = y[t] = s
    }! function t() {
      for (var n = Date.now(); i < _.width;)
        if (r(i), i += b, 25 < Date.now() - n) return void setTimeout(t, 25);
      a(y, _, m, e)
    }()
  }

  function c(i, o, t) {
    var n, e, a = (n = L, e = T, A.indexFor = function(t) {
          return Math.max(0, Math.min(A.length - 1, Math.round((t - n) / (e - n) * (A.length - 1))))
        }, A),
        s = a.map(function() {
          return []
        }),
        t = (t.south - t.north) * (t.west - t.east),
        t = Math.pow(t, .2),
        r = Math.round(i.width * i.height * S * t);
    /android|blackberry|iemobile|ipad|iphone|ipod|opera mini|webos/i.test(navigator.userAgent) && (r *= 1);
    for (var u = [], l = 0; l < r; l++) u.push(o.randomize({
      age: Math.floor(Math.random() * k) + 0
    }));
    var h = f.ctx;
    h.lineWidth = C, h.globalAlpha = .6;
    var c = Date.now();
    ! function t() {
      M && cancelAnimationFrame(M);
      var n = Date.now(),
          e = n - c;
      E < e && (c = n - e % E, s.forEach(function(t) {
        t.length = 0
      }), u.forEach(function(t) {
        t.age > k && (o.randomize(t).age = 0);
        var n = t.x,
            e = t.y,
            i = o(n, e),
            r = i[2];
        null === r ? t.age = k : (n = n + i[0], i = e + i[1], null !== o(n, i)[2] ? (t.xt = n, t.yt = i, s[a.indexFor(r)].push(t)) : (t.x = n, t.y = i)), t.age += 1
      }), h.start2D && h.start2D(), h.globalCompositeOperation = "destination-in", h.start2D || h.fillRect(i.x, i.y, i.width, i.height), h.globalCompositeOperation = "lighter", h.globalAlpha = .92, s.forEach(function(t, n) {
        0 < t.length && (h.beginPath(), h.strokeStyle = a[n], t.forEach(function(t) {
          h.moveTo(t.x, t.y), h.lineTo(t.xt, t.yt), t.x = t.xt, t.y = t.yt
        }), h.stroke())
      }), h.finish2D && h.finish2D()), M = requestAnimationFrame(t)
    }()
  }
  var d, p, _, m, g, v, y, b, w, M, L = f.minVelocity || 0,
      T = f.maxVelocity || 10,
      P = (f.velocityScale || .005) * (Math.pow(window.devicePixelRatio, 1 / 3) || 1),
      k = f.particleAge || 50,
      C = f.lineWidth || 2,
      S = f.particleMultiplier || 1 / 300,
      E = 1e3 / (f.frameRate || 30),
      A = f.colorScale || ["rgb(36,104, 180)", "rgb(60,157, 194)", "rgb(128,205,193 )", "rgb(151,218,168 )", "rgb(198,231,181)", "rgb(238,247,217)", "rgb(255,238,159)", "rgb(252,217,125)", "rgb(255,182,100)", "rgb(252,150,75)", "rgb(250,112,52)", "rgb(245,64,32)", "rgb(237,45,28)", "rgb(220,24,32)", "rgb(180,0,35)"],
      i = [NaN, NaN, null],
      z = f.data,
      N = function(t, n) {
        if (!p) return null;
        var e, i = O(t - m, 360) / v,
            r = (g - n) / y,
            o = Math.floor(i),
            a = o + 1,
            s = Math.floor(r),
            u = s + 1;
        if (e = p[s]) {
          t = e[o], n = e[a];
          if (I(t) && I(n) && (e = p[u])) {
            u = e[o], a = e[a];
            if (I(u) && I(a)) return d.interpolate(i - o, r - s, t, n, u, a)
          }
        }
        return null
      },
      I = function(t) {
        return null != t
      },
      O = function(t, n) {
        return t - n * Math.floor(t / n)
      },
      B = function(t, n, e, i, r, o) {
        var a = 2 * Math.PI,
            s = Math.pow(10, -5.2),
            u = n < 0 ? s : -s,
            l = e < 0 ? s : -s,
            s = R(e, n + u, o),
            o = R(e + l, n, o),
            a = Math.cos(e / 360 * a);
        return [(s[0] - i) / u / a, (s[1] - r) / u / a, (o[0] - i) / l, (o[1] - r) / l]
      },
      R = function(t, n, e) {
        var i = l(e.south),
            r = l(e.north),
            o = e.width / (e.east - e.west),
            i = e.height / (r - i),
            t = l(u(t));
        return [(u(n) - e.west) * o, t = (r - t) * i]
      },
      D = function() {
        Z.field && Z.field.release(), M && cancelAnimationFrame(M)
      },
      Z = {
        params: f,
        start: function(n, e, i, t) {
          var r = {
            south: u(t[0][1]),
            north: u(t[1][1]),
            east: u(t[1][0]),
            west: u(t[0][0]),
            width: e,
            height: i
          };
          D(), z && function(t, n) {
            t = (d = s(t)).header, m = t.lo1, g = t.la1, v = t.dx, y = t.dy, b = t.nx, w = t.ny, (_ = new Date(t.refTime)).setHours(_.getHours() + t.forecastTime), p = [];
            for (var e = 0, i = 360 <= Math.floor(b * v), r = 0; r < w; r++) {
              for (var o = [], a = 0; a < b; a++, e++) o[a] = d.data(e);
              i && o.push(o[0]), p[r] = o
            }
            n({
              date: _,
              interpolate: N
            })
          }(z, function(t) {
            h(t, function(t, n, e) {
              var i = t[0],
                  r = t[1],
                  t = Math.round(i[0]),
                  i = Math.max(Math.floor(i[1], 0), 0);
              Math.min(Math.ceil(r[0], n), n - 1);
              return {
                x: t,
                y: i,
                xMax: n,
                yMax: Math.min(Math.ceil(r[1], e), e - 1),
                width: n,
                height: e
              }
            }(n, e, i), r, function(t, n, e) {
              Z.field = n, c(t, n, e)
            })
          })
        },
        stop: D,
        createField: a,
        interpolatePoint: N,
        setData: function(t) {
          z = t
        },
        setColorSM: function(t, n, e) {
          A = t, P = n, S = e
        }
      };
  return Z
};
window.cancelAnimationFrame || (window.cancelAnimationFrame = function(t) {
  clearTimeout(t)
}), L.WindUtil = L.Class.extend({
  options: {
    width: 1,
    height: 1,
    mapColorScale: [{
      content: "优",
      background: "#36ea00",
      color: "#000000"
    }, {
      content: "良",
      background: "#feff00",
      color: "#000000"
    }, {
      content: "轻度",
      background: "#fb8000",
      color: "#000000"
    }, {
      content: "中度",
      background: "#f90000",
      color: "#feffff"
    }, {
      content: "重度",
      background: "#98004d",
      color: "#feffff"
    }, {
      content: "严重",
      background: "#7d0021",
      color: "#feffff"
    }],
    products: {
      temp: {
        type: "temp",
        suffix: "png",
        title: "温度",
        range: [193, 206, 219, 233.15, 255.372, 273.15, 291, 301, 311, 328],
        color: [
          [37, 4, 42, .6],
          [41, 10, 130, .6],
          [81, 40, 40, .6],
          [192, 37, 149, .6],
          [70, 215, 215, .6],
          [21, 84, 187, .6],
          [24, 132, 14, .6],
          [247, 251, 59, .6],
          [235, 167, 21, .6],
          [230, 71, 39, .6],
          [88, 27, 67, .6]
        ],
        units: [{
          label: "°C",
          conversion: function(t) {
            return t - 273.15
          },
          precision: 0
        }, {
          label: "°F",
          conversion: function(t) {
            return 9 * t / 5 - 459.67
          },
          precision: 0
        }, {
          label: "K",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      relative_humidity: {
        type: "relative_humidity",
        suffix: "png",
        title: "相对湿度",
        range: [0, 25, 60, 75, 90, 100],
        color: [
          [230, 165, 30, .6],
          [120, 100, 95, .6],
          [40, 44, 92, .6],
          [21, 13, 193, .6],
          [75, 63, 235, .6],
          [25, 255, 255, .6]
        ],
        units: [{
          label: "%",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      wind: {
        type: "wind",
        suffix: "png",
        title: "风场",
        range: [0, 2, 4, 6, 8, 10,12,14,16,18,20,24,27,29],
        color: [
          [37, 74, 255,.6],
          [0, 150, 254, .6],
          [18, 196, 200, .6],
          [18, 211, 73, .6],
          [0, 240, 0, .6],
          [127, 237, 0, .6],
          [254, 199, 0, .6],
          [237, 124, 14, .6],
          [200, 37, 39, .6],
          [217, 0, 100, .6],
          [202, 25, 186, .6],
          [86, 54, 222, .6],
          [42, 132, 222, .6],
          [64, 199, 222, .6],
        ],
        units: [{
          label: "m/s",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      precipitation: {
        type: "precipitation",
        suffix: "png",
        title: "降水量",
        range: [.1, .2, .5, 1, 2, 4, 6, 8, 10, 15, 20, 30, 40, 50],
        color: [
          [117, 117, 117, .6],
          [91, 87, 137, .6],
          [73, 102, 170, .6],
          [70, 153, 171, .6],
          [83, 184, 100, .6],
          [145, 206, 76, .6],
          [206, 218, 62, .6],
          [220, 182, 64, .6],
          [219, 158, 69, .6],
          [217, 121, 77, .6],
          [210, 96, 95, .6],
          [179, 56, 103, .6],
          [147, 23, 78, .6],
          [84, 16, 41, .6]
        ],
        units: [{
          label: "mm",
          conversion: function(t) {
            return t
          }
        }, {
          label: "kg/m²",
          conversion: function(t) {
            return t
          }
        }]
      },
      wind_speed: {
        type: "wind_speed",
        suffix: "png",
        title: "风速",
        "range": [0, 1, 5, 10, 15, 20, 25, 30, 35, 50, 60],
        "color": [
            [98, 113, 183, 1],  // 对应 value: 0
            [57, 97, 159, 1],   // 对应 value: 1
            [74, 148, 169, 1],  // 对应 value: 5
            [53, 159, 53, 1],   // 对应 value: 10
            [161, 108, 92, 1],  // 对应 value: 15
            [175, 80, 136, 1],  // 对应 value: 20
            [109, 97, 163, 1],  // 对应 value: 25
            [92, 144, 152, 1],  // 对应 value: 30
            [125, 68, 165, 1],  // 对应 value: 35
            [231, 215, 215, 1], // 对应 value: 50
            [205, 202, 112, 1]  // 对应 value: 60
        ],
        units: [{
            label: "m/s",
            conversion: function(t) {
                return t;
            },
            precision: 2
        }]
      },
      pollutant_conc: {
        type: "pollutant_conc",
        suffix: "png",
        title: "污染物浓度",
        'range': [0.0, 0.01, 0.05, 0.1, 0.15, 0.3, 0.8, 1.0, 3.0, 6.0, 10.0],
        'color': [
            [216,222,222, 1],   // 对应 value: 0.0 (几乎无污染)
            [71, 75, 141, 1],   // 对应 value: 0.01 (非常低浓度)
            [71, 75, 141, 1],   // 对应 value: 0.05
            [111, 187, 220, 1], // 对应 value: 0.1
            [71, 101, 99, 1],   // 对应 value: 0.2
            [125, 180, 54, 1],  // 对应 value: 0.5
            [172, 200, 61, 1],  // 对应 value: 1.0
            [232, 231, 72, 1],  // 对应 value: 2.0
            [235, 183, 59, 1],  // 对应 value: 5.0
            [224, 101, 49, 1],  // 对应 value: 10.0
            [217, 67, 45, 1]    // 对应 value: 50.0 (最高浓度)
        ],
        units: [{
            label: "μg/m³",
            conversion: function(c) {
                return c;
            },
            precision: 3 // 设置精度为3位小数，以准确表示小数值
        }]
      },
      cloud_cover: {
        type: "cloud_cover",
        suffix: "png",
        title: "云量",
        range: [0, 10, 50, 95, 98, 100],
        color: [
            [146, 130, 70, 1], // 对应 value: 0
            [132, 119, 70, 1], // 对应 value: 10
            [116, 116, 116, 1], // 对应 value: 50
            [171, 180, 179, 1], // 对应 value: 95
            [198, 201, 201, 1], // 对应 value: 98
            [213, 213, 205, 1]  // 对应 value: 100
        ],
        units: [{
          label: "%",
          conversion: function(t) {
            return t;
          }
        }]
      },
      pressure: {
          type: "pressure",
          suffix: "png",
          title: "气压",
          range: [990, 995, 1000, 1005, 1010, 1015, 1020, 1025, 1030],
          color: [
                [0, 90, 148, .9],    
                [0, 117, 146, .9],   
                [26, 140, 147, .9], 
                [103, 162, 155, .9],
                [155, 183, 172, .9], 
                [176, 174, 152, .9], 
                [167, 147, 107, .9],  
                [163, 116, 67, .9],   
                [159, 81, 44, .9]    
            ],
          units: [{
                "label": "hPa",
                "conversion": function(t) {
                    return t;
                },
                "precision": 0
            }]
      },
      aqi: {
        type: "aqi",
        suffix: "png",
        title: "空气质量指数",
        range: [0, 50, 100, 150, 200, 300, 400, 500],
        color: [
          [0, 288, 0, .6],
          [255, 255, 0, .6],
          [255, 126, 0, .6],
          [255, 0, 0, .6],
          [153, 0, 76, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6]
        ],
        units: [{
          label: "",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      no2: {
        type: "no2",
        suffix: "png",
        title: "二氧化氮",
        range: [0, 100, 200, 700, 1200, 2340, 3090, 3840],
        color: [
          [0, 288, 0, .6],
          [255, 255, 0, .6],
          [255, 126, 0, .6],
          [255, 0, 0, .6],
          [153, 0, 76, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6]
        ],
        units: [{
          label: "µg/m³",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      so2: {
        type: "so2",
        suffix: "png",
        title: "二氧化硫",
        range: [0, 150, 500, 650, 800],
        color: [
          [0, 288, 0, .6],
          [255, 255, 0, .6],
          [255, 126, 0, .6],
          [255, 0, 0, .6],
          [153, 0, 76, .6]
        ],
        units: [{
          label: "µg/m³",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      co: {
        type: "co",
        suffix: "png",
        title: "一氧化碳",
        range: [0, 5, 10, 35, 60, 90, 120, 150],
        color: [
          [0, 288, 0, .6],
          [255, 255, 0, .6],
          [255, 126, 0, .6],
          [255, 0, 0, .6],
          [153, 0, 76, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6]
        ],
        units: [{
          label: "mg/m³",
          conversion: function(t) {
            return t
          },
          precision: 1
        }]
      },
      pm25: {
        type: "pm2_5",
        suffix: "png",
        title: "细颗粒物(PM2.5)",
        range: [0, 35, 75, 115, 150, 250, 350, 500],
        color: [
          [0, 288, 0, .6],
          [255, 255, 0, .6],
          [255, 126, 0, .6],
          [255, 0, 0, .6],
          [153, 0, 76, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6]
        ],
        units: [{
          label: "µg/m³",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      pm10: {
        type: "pm10",
        suffix: "png",
        title: "颗粒物(PM10)",
        range: [0, 50, 150, 250, 350, 420, 500, 600],
        color: [
          [0, 288, 0, .6],
          [255, 255, 0, .6],
          [255, 126, 0, .6],
          [255, 0, 0, .6],
          [153, 0, 76, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6]
        ],
        units: [{
          label: "µg/m³",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      o3: {
        type: "o3",
        suffix: "png",
        title: "臭氧",
        range: [0, 160, 200, 300, 400, 800, 1e3, 1200],
        color: [
          [0, 288, 0, .6],
          [255, 255, 0, .6],
          [255, 126, 0, .6],
          [255, 0, 0, .6],
          [153, 0, 76, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6],
          [126, 0, 35, .6]
        ],
        units: [{
          label: "µg/m³",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      dswrf: {
        type: "dswrf",
        suffix: "jpg",
        title: "辐射量",
        range: [100, 200, 300, 400, 500, 600, 700, 800, 900, 1e3, 1100, 1200],
        color: [
          [80, 148, 181, .9],
          [59, 155, 189, .9],
          [90, 216, 117, .9],
          [137, 215, 79, .9],
          [186, 222, 73, .9],
          [239, 247, 71, .9],
          [241, 180, 52, .9],
          [248, 125, 32, .9],
          [212, 77, 11, .9],
          [191, 56, 8, .9],
          [184, 31, 13, .9],
          [148, 7, 9, .9]
        ],
        units: [{
          label: "W/m²",
          conversion: function(t) {
            return t
          },
          precision: 0
        }]
      },
      pslv: {
        type: "pslv",
        suffix: "jpg",
        title: "海平面气压",
        range: [990, 995, 1e3, 1005, 1010, 1015, 1020, 1025, 1030, 1035, 1040, 1045, 1050],
        color: [[40, 9, 119, .9], [61, 25, 83, .9], [110, 39, 69, .9], [151, 96, 171, .9], [63, 197, 211, .9], [21, 88, 169, .9], [22, 114, 77, .9], [79, 161, 25, .9], [213, 233, 52, .9], [236, 178, 26, .9], [230, 77, 37, .9], [144, 44, 55, .9]],
        units: [{
            label: "hPa",
            conversion: function(t) {
                return t
            },
            precision: 0
        }]
      },
      dusmass: {
          type: "dusmass",
          suffix: "png",
          title: "沙尘",
          range: [0, 50, 150, 250, 500, 600],
          color: [[42, 102, 105, .9], [111, 185, 55, .9], [196, 199, 64, .9], [240, 214, 187, .9], [251, 251, 251, .9]],
          units: [{
              label: "µg/m³",
              conversion: function(t) {
                  return t
              },
              precision: 0
          }]
      }
    }
  },
  initialize: function(t, n) {
    this.name = t, L.setOptions(this, n)
  },
  getAllDate: function(t, n) {
    var e = [];
    e.push(n);
    for (var i = new Date(t), r = new Date(n); 0 < new Date(r).getTime() - new Date(i).getTime();) r = new Date(r).getTime() - 864e5, e.push(this.rebuildTime(r, 1));
    return e
  },
  rebuildTime: function(t, n) {
    var e = new Date(t),
        i = e.getFullYear(),
        r = e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1,
        o = e.getDate() < 10 ? "0" + e.getDate() : e.getDate(),
        a = e.getHours() < 10 ? "0" + e.getHours() : e.getHours(),
        s = e.getMinutes() < 10 ? "0" + e.getMinutes() : e.getMinutes(),
        u = e.getSeconds() < 10 ? "0" + e.getSeconds() : e.getSeconds(),
        e = "星期" + "日一二三四五六".charAt(e.getDay());
    return 1 == n ? i + "-" + r + "-" + o : 2 == n ? i + "年" + r + "月" + o + "日" : 3 == n ? i + "-" + r + "-" + o + " " + a + ":" + s : 4 == n ? i + "-" + r + "-" + o + " " + a + ":" + s + ":" + u : 5 == n ? i + "-01-01 00:00:00" : 6 == n ? i + "/" + r + "/" + o : 7 == n ? i + "/" + r + "/" + o + " 00:00:00" : 8 == n ? a + ":" + s : 9 == n ? 40 < s ? i + "-" + r + "-" + o + " " + a + ":00" : this.rebuildTime(t - 3600, 9) : 10 == n ? i + "-" + r : 11 == n ? i + "" + r + o : 13 == n ? i + "-" + r + "-" + o + " 00:00:00 +0800" : 14 == n ? r + "月" + o + "日 " + e : 15 == n ? i + "" + r + o + a : 17 == n ? r + "月" + o + "日" : 18 == n ? r + "-" + o : 19 == n ? i + "-" + r + "-" + o + " " + a + ":00:00" : 20 == n ? i + "-" + r + "-" + o + " " + a + ":00" : 21 == n ? i + "年" + r + "月" + o + "日 " + e + " " + a + ":" + s : 22 == n ? i + "-" + r + "-" + o + " 00:00" : 23 == n ? i + "/" + r + "/" + o + " 00:00" : i + "年" + r + "月" + o + "日" + a + "时"
  },
  checkOs: function() {
    var t = navigator.userAgent,
        n = /(?:Windows Phone)/.test(t),
        e = /(?:SymbianOS)/.test(t) || n,
        i = /(?:Android)/.test(t),
        n = /(?:Firefox)/.test(t),
        n = (/(?:Chrome|CriOS)/.test(t), /(?:iPad|PlayBook)/.test(t) || i && !/(?:Mobile)/.test(t) || n && /(?:Tablet)/.test(t)),
        t = /(?:iPhone)/.test(t) && !n;
    return {
      isTablet: n,
      isPhone: t,
      isAndroid: i,
      isPc: !t && !i && !e
    }
  },
  getUrlParams: function(t) {
    t = new RegExp("(^|&)" + t + "=([^&]*)(&|$)"), t = window.location.search.substr(1).match(t);
    return null != t ? decodeURI(t[2]) : null
  },
  checkLevel: function(t, e) {
    var n = {
          aqi: [0, 50, 100, 150, 200, 300],
          so2: [0, 150, 500, 650, 800, 1600],
          no2: [0, 100, 200, 700, 1200, 2340],
          pm10: [0, 50, 150, 250, 350, 420],
          co: [0, 5, 10, 35, 60, 90],
          o3: [0, 160, 200, 300, 400, 800],
          pm25: [0, 35, 75, 115, 150, 250]
        },
        i = 1;
    return n[t] && n[t].forEach(function(t, n) {
      Number(e) > t && (i = n + 1)
    }), i
  },
  changeColor: function(t) {
    return 301 <= t ? {
      background: "#7d0021",
      color: "#fff"
    } : 201 <= t && t < 301 ? {
      background: "#98004d",
      color: "#fff"
    } : 151 <= t && t < 201 ? {
      background: "#f90000",
      color: "#fff"
    } : 101 <= t && t < 151 ? {
      background: "#fb8000",
      color: "#000"
    } : 51 <= t && t < 101 ? {
      background: "#feff00",
      color: "#000"
    } : 0 <= t && t < 51 ? {
      background: "#36ea00",
      color: "#000"
    } : {}
  },
  changeTxtColor: function(t) {
    return 301 <= t ? {
      color: "#7d0021"
    } : 201 <= t && t < 301 ? {
      color: "#98004d"
    } : 151 <= t && t < 201 ? {
      color: "#f90000"
    } : 101 <= t && t < 151 ? {
      color: "#fb8000"
    } : 51 <= t && t < 101 ? {
      color: "#feff00"
    } : 0 <= t && t < 51 ? {
      color: "#36ea00"
    } : {}
  },
  changeGrade: function(t) {
    return 0 <= t && t < 51 ? "优" : 51 <= t && t < 101 ? "良" : 101 <= t && t < 151 ? "轻" : 151 <= t && t < 201 ? "中" : 201 <= t && t < 301 ? "重" : 301 <= t ? "严重" : {}
  },
  changeTxtGrade: function(t) {
    return 0 <= t && t < 51 ? "优" : 51 <= t && t < 101 ? "良" : 101 <= t && t < 151 ? "轻度污染" : 151 <= t && t < 201 ? "中度污染" : 201 <= t && t < 301 ? "重度污染" : 301 <= t ? "严重污染" : {}
  },
  changeMainPollutant: function(t, n) {
    return t <= 50 ? "—" : 0 == n ? "CO" : 1 == n ? "SO2" : 2 == n ? "NO2" : 3 == n ? "PM2.5" : 4 == n ? "PM10" : 5 == n ? "O3" : ""
  },
  changeSpeed: function(t) {
    return null == t ? null : 0 <= t && t <= .2 ? 0 : .3 <= t && t <= 1.5 ? 1 : 1.6 <= t && t <= 3.3 ? 2 : 3.4 <= t && t <= 5.4 ? 3 : 5.5 <= t && t <= 7.9 ? 4 : 8 <= t && t <= 10.7 ? 5 : 10.8 <= t && t <= 13.8 ? 6 : 13.9 <= t && t <= 17.1 ? 7 : 17.2 <= t && t <= 20.7 ? 8 : 20.8 <= t && t <= 24.4 ? 9 : 24.5 <= t && t <= 28.4 ? 10 : 28.5 <= t && t <= 32.6 ? 11 : 12
  },
  timeRange: function(t, n, e) {
    t = new Date(t), t = new Date(n).getTime() - t.getTime();
    return "hour" == e ? Math.floor(t / 1e3 / 60 / 60) : "day" == e ? Math.floor(t / 1e3 / 60 / 60 / 24) : "month" == e ? Math.floor(t / 1e3 / 60 / 60 / 24 / 30) : void 0
  },
  changeDirection: function(t) {
    return null == t ? null : 0 <= t && t <= 22.5 ? "北风" : 22.6 <= t && t <= 67.5 ? "东北风" : 67.6 <= t && t <= 112.5 ? "东风" : 112.6 <= t && t <= 157.5 ? "东南风" : 157.6 <= t && t <= 202.5 ? "南风" : 202.6 <= t && t <= 247.5 ? "西南风" : 247.6 <= t && t <= 292.5 ? "西风" : 292.6 <= t && t <= 337.5 ? "西北风" : ""
  },
  async getHourlyImages(startDate, endDate, product) {
        const result = {};
        let currentDate = new Date(startDate);
        while (currentDate <= endDate) {
            const year = currentDate.getFullYear();
            const month = String(currentDate.getMonth() + 1).padStart(2, '0');
            const day = String(currentDate.getDate()).padStart(2, '0');
            for (let hour = 0; hour < 24; hour++) {
                const hourStr = String(hour).padStart(2, '0');
                const timestamp = `${year}-${month}-${day}T${hourStr}:00:00`;
                try {
                    const decodedData = await this.getImgDataForHostory(timestamp, product);
                    result[timestamp] = decodedData;
                } catch (error) {
                    console.error(`Error fetching data for ${timestamp}:`, error);
                }
            }
            currentDate.setDate(currentDate.getDate() + 1);
        }
        return result;
    },

    getImgDataForHostory: function(t, n) {
        return new Promise((resolve, reject) => {
          // 确保 t 是一个 Date 对象
          const date = new Date(t);
          const url = `${weatherUrl}/data/weather/${date.getFullYear()}/${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')}/${String(date.getHours()).padStart(2, '0')}00-${n.type}-surface-level-gfs-0.25.${n.suffix}`;
          // console.log(url);
          const img = new Image();
          img.crossOrigin = "Anonymous";
          img.onload = () => {
              const canvas = document.createElement("canvas");
              const context = canvas.getContext("2d");
              canvas.width = img.width;
              canvas.height = img.height;
              context.drawImage(img, 0, 0);
              
              const imageData = context.getImageData(0, 0, img.width, img.height).data;
              try {
                  const decodedData = this.decodeImage(imageData, url, img.width);
                  resolve(decodedData);
              } catch (decodeError) {
                  reject(new Error(`Failed to decode image from ${url}: ${decodeError.message}`));
              }
          };
          img.onerror = () => {
              reject(new Error(`Failed to load image from ${url}`));
          };
          img.src = url;
      });
    },
    getResultImgData: function(t, n) {
      return new Promise((resolve, reject) => {
        // 确保 t 是一个 Date 对象
        const date = new Date(t);
        const url = `${weatherUrl}/data/calpuff/${date.getFullYear()}/${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')}/0000-l00-so2-conc.${n.suffix}`;
        console.log(url);
        const img = new Image();
        img.crossOrigin = "Anonymous";
        img.onload = () => {
            const canvas = document.createElement("canvas");
            const context = canvas.getContext("2d");
            canvas.width = img.width;
            canvas.height = img.height;
            context.drawImage(img, 0, 0);
            
            const imageData = context.getImageData(0, 0, img.width, img.height).data;
            try {
                const decodedData = this.decodeResultImage(imageData, url, img.width);
                resolve(decodedData);
            } catch (decodeError) {
                reject(new Error(`Failed to decode image from ${url}: ${decodeError.message}`));
            }
        };
        img.onerror = () => {
            reject(new Error(`Failed to load image from ${url}`));
        };
        img.src = url;
    });
  },
  decodeResultImage: function(imageData, url, width) {
    var i = /.*(\d{4})\/(\d{1,2})\/(\d{1,2})\/(\d{3,4})/.exec(url),
        r = i[1] + "-" + i[2] + "-" + i[3] + "T" + i[4].substr(0, 2) + ":00:00.000Z",
        headHeight = 3,
        i = this.decodeResultHead(imageData, width,headHeight);
    i.refTime = r;
    for (var s, u = [], l = [], r = [], h = imageData.length, c = headHeight * width * 4; c < h; c += 4) {
        u.push(imageData[c]);
        l.push(imageData[c + 1]);
    }      
    s = this.decodeBody(i, u);
    r.push({
        header: i,
        data: s
    });
    return r;
  },
  decodeResultHead: function(imageData, width,headHeight) {
    for (var e = [], i = 0; i < 4 * width*headHeight; i += 4) e.push(imageData[i]);
    console.log(e)
    for (var r = [], o = e.length, i = 0; i < o; i++) 0 != e[i] && r.push(String.fromCharCode(e[i]));
    return JSON.parse("{" + r.join("") + "}")
  },
  getImgUrl: function(t, n) {
    // t = new Date(t.getTime() - 36e5);
    let url = weatherUrl + "/data/weather/" + t.getFullYear() + "/" + (t.getMonth() + 1 < 10 ? "0" + (t.getMonth() + 1) : t.getMonth() + 1) + "/" + (t.getDate() < 10 ? "0" + t.getDate() : t.getDate()) + "/" + (t.getHours() < 10 ? "0" + t.getHours() : t.getHours()) + "00-" + n.type + "-surface-level-gfs-0.25." + n.suffix
    console.log(url)
    return url
  },
  getImgData: function(t, n, e, typeNum = 0) {
    _fcTypeNum = typeNum;
    var i, r = this.getImgUrl(t, n),
        o = this,
        a = document.createElement("canvas"),
        s = a.getContext("2d"),
        u = new Image;
    u.crossOrigin = "Anonymous";
    u.onload = function() {
      try {
          a.width = u.width;
          a.height = u.height;
          s.drawImage(u, 0, 0);
          var imageData = s.getImageData(0, 0, u.width, u.height).data;
          i = o.decodeImage(imageData, r, u.width);
          e(i);
      } catch (err) {
          console.error("解码图像数据时出错:", err);
          e(null, err); // 通过回调返回错误信息
      }
    };
    u.src = r;
    u.onerror = function() {
        console.error("图片加载失败:", r);
        e(null, new Error("图片加载失败")); // 通过回调返回错误信息
    };
  },
  decodeImage: function(t, n, e) {
    var i = /.*(\d{4})\/(\d{1,2})\/(\d{1,2})\/(\d{3,4})/.exec(n),
        r = i[1] + "-" + i[2] + "-" + i[3] + "T" + i[4].substr(0, 2) + ":00:00.000Z",
        o = /wind/.test(n),
        a = 8,
        i = {};
    /png/.test(n) ? (a = 1, i = this.decodeHead(t, e)) : (i = this.decodeHeadJPG(t, e)).refTime = r;
    for (var s, u = [], l = [], r = [], h = t.length, c = a * e * 4; c < h; c += 4) u.push(t[c]), l.push(t[c + 1]);
    // 根据条件 o 的值决定如何解码数据并将其推入数组 r 中
    if (o) {
      // 条件为真时的处理
      s = this.decodeBody(i, u);
      r.push({
          header: i,
          data: s
      });

      o = this.decodeBody(i, l);
      r.push({
          header: i,
          data: o
      });
    } else {
      // 条件为假时的处理
      s = this.decodeBody(i, u);
      r.push({
          header: i,
          data: s
      });
    }
    return r;
  },
  decodeHeadJPG: function(t, n) {
    for (var e = 4 * n * 4 + 8, i = 4 * n * 4 + 704, n = new ArrayBuffer(44), r = new Uint8Array(n), n = new Float32Array(n), o = 0, a = e; a < i; a += 16) {
      var s = t[a],
          u = t[a + 1],
          l = t[a + 2],
          s = Math.round(s / 64),
          u = Math.round(u / 16),
          l = Math.round(l / 64);
      r[o] = (s << 6) + (u << 2) + l, o += 1
    }
    e = {
      isForecast: 0,
      nx: 0,
      ny: 0,
      lo1: 0,
      lo2: 359.8,
      la1: 90,
      la2: -90,
      dx: .25,
      dy: .25,
      max: 328.15,
      min: 193.15
    };
    return e.isForecast = n[0], e.nx = n[1], e.ny = n[2], e.lo1 = n[3], e.lo2 = n[4], e.la1 = n[5], e.la2 = n[6], e.dx = n[7], e.dx = n[7], e.dy = n[8], e.max = n[9], e.min = n[10], e
  },
  decodeHead: function(t, n) {
    for (var e = [], i = 0; i < 4 * n; i += 4) e.push(t[i]);
    for (var r = [], o = e.length, i = 0; i < o; i++) 0 != e[i] && r.push(String.fromCharCode(e[i]));
    return JSON.parse("{" + r.join("") + "}")
  },
  decodeBody: function(t, n, e) {
    return this.unscaleArr(n, t.min, t.max, e)
  },
  unscaleArr: function(t, n, e, i) {
    for (var r = t.length, o = 0; o < r; o++) t[o] < 5 ? t[o] = null : (t[o] < 10 && (t[o] = 10), t[o] = this.unscale(t[o], n, e));
    return t
  },
  unscale: function(t, n, e) {
    var i = [10, 255];
    return (e - n) * (t - i[0]) / (i[1] - i[0]) + n
  }
}), L.windUtil = function(t) {
  return new L.WindUtil(t)
}, L.ScaleLayer = L.GridLayer.extend({
  options: {
    _color: null,
    _interpolate: !1,
    _map: null,
    _field: null,
    _canvases: {},
    _product: null,
    _old_tiles: []
  },
  setData: function(t, n) {
    this.options._field = t, this.options._product = n;
    var e, i = document.createDocumentFragment();
    for (e in this._tiles) {
      var r = this._tiles[e].coords;
      this._addTile(r, i)
    }
    this._level && this._level.el.appendChild(i)
  },
  setColor: function(t) {
    this.options._color = t
  },
  prepareImageIn: function(t, n, e) {
    var i = e.x,
        r = e.y,
        o = n.scaleBy(e),
        a = 0,
        s = 1;
    4 < n.z && (s = 2), 7 < n.z && (s = 4), 10 < n.z && (s = 8), 13 < n.z && (s = 16);
    for (var u = 0; u < r; u += s) {
      for (var l = 0; l < i; l += s) {
        var h = this.options._map.unproject(o.add([l, u]), n.z),
            h = this.options._field.interpolatedValueAt(h.lng, h.lat);
        if (null !== h)
          for (var h = this.options._color(h).rgba(), c = h[0], f = h[1], d = h[2], p = (h[3], 0); p < s; p++)
            for (var _ = 0; _ < s; _++) t[a + 4 * i * p + 4 * _] = c, t[a + 4 * i * p + 4 * _ + 1] = f, t[a + 4 * i * p + 4 * _ + 2] = d, t[a + 4 * i * p + 4 * _ + 3] = 255;
        a += 4 * s
      }
      a += (i - (i % 2 != 0 ? 1 : 0)) * (s - 1) * 4
    }
  },
  onAdd: function(t) {
    // this._currentPoint = document.getElementById("currentPoint"), this._mapBox = t._container, document.getElementById("scale-value").style.display = "block", t.on("mousemove", this._onMouseMove, this), this.options._map = t, null != this.options._field && L.GridLayer.prototype.onAdd.call(this, t)
    this._currentPoint = document.getElementById("currentPoint"), this._mapBox = t._container, document.getElementById("scale-value").style.display = "none", t.on("mousemove", this._onMouseMove, this), this.options._map = t, null != this.options._field && L.GridLayer.prototype.onAdd.call(this, t)
  },
  onRemove: function(t) {
    t.off("mousemove", this._onMouseMove, this), document.getElementById("scale-value").style.display = "none", document.getElementById("scale-value").innerHTML = "", document.getElementById("currentPoint").style.display = "none", L.GridLayer.prototype.onRemove.call(this, t)
  },
  _onMouseMove: function(t) {
    var n = this,
        e = this.options._map.containerPointToLatLng(L.point(t.containerPoint.x, t.containerPoint.y)),
        e = this.options._field.valueAt(e.lng, e.lat);
    n._currentPoint && (t.containerPoint.x > n._mapBox.clientWidth - 200 ? n._currentPoint.style.left = n._mapBox.clientWidth + 432 + "px" : n._currentPoint.style.left = t.containerPoint.x + 632 + "px", t.containerPoint.y > n._mapBox.clientHeight - 30 ? n._currentPoint.style.top = n._mapBox.clientHeight - 30 + "px" : n._currentPoint.style.top = t.containerPoint.y + "px",n._currentPoint.style.zIndex=1001);
    n = this.options._product, t = "";
    // console.log(n);
    e && (t = n.title + ": " + n.units[0].conversion(e).toFixed(n.units[0].precision) + " " + n.units[0].label), document.getElementById("scale-value").innerHTML = t
  },
  createTile: function(t) {
    var n, e, i = null,
        r = t.z + "-" + t.x + "-" + t.y,
        o = null;
    this.options._canvases[r] && this.options._old_tiles.push(this.options._canvases[r]), i = L.DomUtil.create("canvas", "leaflet-tile"), this.options._canvases[r] = i, e = this.getTileSize(), i.width = e.x, i.height = e.y;
    r = (n = (o = i.getContext("2d")).createImageData(i.width, i.height)).data;
    return this.prepareImageIn(r, t, e), o.putImageData(n, 0, 0), i
  }
}), L.scaleLayer = function(t) {
  return new L.ScaleLayer(t)
},
    function(e) {
      function i(t) {
        if (r[t]) return r[t].exports;
        var n = r[t] = {
          i: t,
          l: !1,
          exports: {}
        };
        return e[t].call(n.exports, n, n.exports, i), n.l = !0, n.exports
      }
      var r = {};
      i.m = e, i.c = r, i.i = function(t) {
        return t
      }, i.d = function(t, n, e) {
        i.o(t, n) || Object.defineProperty(t, n, {
          configurable: !1,
          enumerable: !0,
          get: e
        })
      }, i.n = function(t) {
        var n = t && t.__esModule ? function() {
          return t.default
        } : function() {
          return t
        };
        return i.d(n, "a", n), n
      }, i.o = function(t, n) {
        return Object.prototype.hasOwnProperty.call(t, n)
      }, i.p = "", i(i.s = 13)
    }([function(t, n, e) {
      var i = (function(t, n, e) {
        return n && o(t.prototype, n), e && o(t, e), t
      }(r, [{
        key: "equals",
        value: function(t) {
          return this.center.equals(t.center) && this._equalValues(this.value, t.value) && this.xSize === t.xSize && this.ySize === t.ySize
        }
      }, {
        key: "_equalValues",
        value: function(t, n) {
          var e = t.constructor.name;
          return {
            Number: t === n,
            Vector: t.u === n.u && t.v === n.v
          } [e]
        }
      }, {
        key: "getBounds",
        value: function() {
          var t = this.xSize / 2,
              n = this.ySize / 2,
              e = this.center.lat,
              i = this.center.lng,
              r = L.latLng([e + n, i - t]),
              t = L.latLng([e - n, i + t]);
          return L.latLngBounds(L.latLng(t.lat, r.lng), L.latLng(r.lat, t.lng))
        }
      }]), r);

      function r(t, n, e) {
        var i = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : e;
        (function(t) {
          if (!(t instanceof r)) throw new TypeError("Cannot call a class as a function")
        })(this), this.center = t, this.value = n, this.xSize = e, this.ySize = i
      }

      function o(t, n) {
        for (var e = 0; e < n.length; e++) {
          var i = n[e];
          i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
        }
      }
      n.a = i
    }, function(t, n, e) {
      var a = e(0),
          i = e(11),
          r = e.n(i),
          u = function(t, n) {
            if (Array.isArray(t)) return t;
            if (Symbol.iterator in Object(t)) return function(t, n) {
              var e = [],
                  i = !0,
                  r = !1,
                  o = void 0;
              try {
                for (var a, s = t[Symbol.iterator](); !(i = (a = s.next()).done) && (e.push(a.value), !n || e.length !== n); i = !0);
              } catch (t) {
                r = !0, o = t
              } finally {
                try {
                  !i && s.return && s.return()
                } finally {
                  if (r) throw o
                }
              }
              return e
            }(t, n);
            throw new TypeError("Invalid attempt to destructure non-iterable instance")
          },
          i = (function(t, n, e) {
            return n && s(t.prototype, n), e && s(t, e), t
          }(o, [{
            key: "_buildGrid",
            value: function() {
              throw new TypeError("Must be overriden")
            }
          }, {
            key: "_updateRange",
            value: function() {
              this.range = this._calculateRange()
            }
          }, {
            key: "numCells",
            value: function() {
              return this.nRows * this.nCols
            }
          }, {
            key: "getCells",
            value: function() {
              for (var t = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : 1, n = [], e = 0; e < this.nRows; e += t)
                for (var i = 0; i < this.nCols; i += t) {
                  var r = this._lonLatAtIndexes(i, e),
                      o = u(r, 2),
                      r = o[0],
                      o = o[1],
                      o = L.latLng(o, r),
                      r = this._valueAtIndexes(i, e),
                      r = new a.a(o, r, this.cellXSize, this.cellYSize);
                  n.push(r)
                }
              return n
            }
          }, {
            key: "setFilter",
            value: function(t) {
              this._inFilter = t, this._updateRange()
            }
          }, {
            key: "setSpatialMask",
            value: function(t) {
              this._spatialMask = t
            }
          }, {
            key: "extent",
            value: function() {
              var t = this._getWrappedLongitudes(),
                  n = u(t, 2),
                  t = n[0],
                  n = n[1];
              return [t, this.yllCorner, n, this.yurCorner]
            }
          }, {
            key: "_getWrappedLongitudes",
            value: function() {
              var t = this.xllCorner,
                  n = this.xurCorner;
              return this.longitudeNeedsToBeWrapped && (this.isContinuous ? (t = -180, n = 180) : (n = this.xurCorner - 360, t = this.xllCorner - 360)), [t, n]
            }
          }, {
            key: "contains",
            value: function(t, n) {
              return this._spatialMask ? this._pointInMask(t, n) : this._pointInExtent(t, n)
            }
          }, {
            key: "_pointInExtent",
            value: function(t, n) {
              var e = this._getWrappedLongitudes(),
                  i = u(e, 2),
                  e = i[0],
                  i = i[1],
                  i = e <= t && t <= i,
                  n = n >= this.yllCorner && n <= this.yurCorner;
              return i && n
            }
          }, {
            key: "_pointInMask",
            value: function(t, n) {
              t = {
                type: "Feature",
                geometry: {
                  type: "Point",
                  coordinates: [t, n]
                },
                properties: {}
              }, n = this._spatialMask;
              return r()(t, n)
            }
          }, {
            key: "notContains",
            value: function(t, n) {
              return !this.contains(t, n)
            }
          }, {
            key: "interpolatedValueAt",
            value: function(t, n) {
              if (this.notContains(t, n)) return null;
              t = this._getDecimalIndexes(t, n), n = u(t, 2), t = n[0], n = n[1];
              return this.interpolatedValueAtIndexes(t, n)
            }
          }, {
            key: "interpolatedValueAtIndexes",
            value: function(t, n) {
              var e = this._getFourSurroundingIndexes(t, n),
                  i = u(e, 4),
                  r = i[0],
                  o = i[1],
                  a = i[2],
                  s = i[3],
                  e = this._getFourSurroundingValues(r, o, a, s);
              if (e) {
                i = u(e, 4), o = i[0], s = i[1], e = i[2], i = i[3];
                return this._doInterpolation(t - r, n - a, o, s, e, i)
              }
              return null
            }
          }, {
            key: "_getDecimalIndexes",
            value: function(t, n) {
              return this.longitudeNeedsToBeWrapped && t < this.xllCorner && (t += 360), [(t - this.xllCorner) / this.cellXSize, (this.yurCorner - n) / this.cellYSize]
            }
          }, {
            key: "_getFourSurroundingIndexes",
            value: function(t, n) {
              var e = Math.floor(t),
                  t = e + 1;
              this.isContinuous && t >= this.nCols && (t = 0), t = this._clampColumnIndex(t);
              n = this._clampRowIndex(Math.floor(n));
              return [e, t, n, this._clampRowIndex(n + 1)]
            }
          }, {
            key: "_getFourSurroundingValues",
            value: function(t, n, e, i) {
              var r;
              if (r = this.grid[e]) {
                var o = r[t],
                    e = r[n];
                if (this._isValid(o) && this._isValid(e) && (r = this.grid[i])) {
                  t = r[t], n = r[n];
                  if (this._isValid(t) && this._isValid(n)) return [o, e, t, n]
                }
              }
              return null
            }
          }, {
            key: "valueAt",
            value: function(t, n) {
              if (this.notContains(t, n)) return null;
              t = this._getDecimalIndexes(t, n), n = u(t, 2), t = n[0], n = n[1], t = Math.floor(t), n = Math.floor(n), t = this._clampColumnIndex(t), n = this._clampRowIndex(n), n = this._valueAtIndexes(t, n);
              return this._inFilter && !this._inFilter(n) ? null : n
            }
          }, {
            key: "hasValueAt",
            value: function(t, n) {
              var e = this.valueAt(t, n),
                  t = null !== e,
                  n = !0;
              return this._inFilter && (n = this._inFilter(e)), t && n
            }
          }, {
            key: "notHasValueAt",
            value: function(t, n) {
              return !this.hasValueAt(t, n)
            }
          }, {
            key: "randomPosition",
            value: function() {
              var t = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {},
                  n = Math.random() * this.nCols | 0,
                  e = Math.random() * this.nRows | 0;
              return t.x = this._longitudeAtX(n), t.y = this._latitudeAtY(e), t
            }
          }, {
            key: "_valueAtIndexes",
            value: function(t, n) {
              return this.grid[n][t]
            }
          }, {
            key: "_lonLatAtIndexes",
            value: function(t, n) {
              return [this._longitudeAtX(t), this._latitudeAtY(n)]
            }
          }, {
            key: "_longitudeAtX",
            value: function(t) {
              var n = this.cellXSize / 2,
                  t = this.xllCorner + n + t * this.cellXSize;
              return this.longitudeNeedsToBeWrapped && (t = 180 < t ? t - 360 : t), t
            }
          }, {
            key: "_latitudeAtY",
            value: function(t) {
              var n = this.cellYSize / 2;
              return this.yurCorner - n - t * this.cellYSize
            }
          }, {
            key: "_doInterpolation",
            value: function(t, n, e, i, r, o) {
              throw new TypeError("Must be overriden")
            }
          }, {
            key: "_clampColumnIndex",
            value: function(t) {
              var n = t;
              t < 0 && (n = 0);
              var e = this.nCols - 1;
              return e < t && (n = e), n
            }
          }, {
            key: "_clampRowIndex",
            value: function(t) {
              var n = t;
              t < 0 && (n = 0);
              var e = this.nRows - 1;
              return e < t && (n = e), n
            }
          }, {
            key: "_isValid",
            value: function(t) {
              return null != t
            }
          }]), o);

      function o(t) {
        (function(t) {
          if (!(t instanceof o)) throw new TypeError("Cannot call a class as a function")
        })(this), this.params = t, this.nCols = t.nCols, this.nRows = t.nRows, this.width = t.nCols, this.height = t.nRows, this.xllCorner = t.xllCorner, this.yllCorner = t.yllCorner, this.xurCorner = t.xllCorner + t.nCols * t.cellXSize, this.yurCorner = t.yllCorner + t.nRows * t.cellYSize, this.cellXSize = t.cellXSize, this.cellYSize = t.cellYSize, this.grid = null, this.isContinuous = 360 <= this.xurCorner - this.xllCorner, this.longitudeNeedsToBeWrapped = 180 < this.xurCorner, this._inFilter = null, this._spatialMask = null
      }

      function s(t, n) {
        for (var e = 0; e < n.length; e++) {
          var i = n[e];
          i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
        }
      }
      n.a = i
    }, function(t, n, e) {
      var i = e(1),
          u = function(t, n) {
            if (Array.isArray(t)) return t;
            if (Symbol.iterator in Object(t)) return function(t, n) {
              var e = [],
                  i = !0,
                  r = !1,
                  o = void 0;
              try {
                for (var a, s = t[Symbol.iterator](); !(i = (a = s.next()).done) && (e.push(a.value), !n || e.length !== n); i = !0);
              } catch (t) {
                r = !0, o = t
              } finally {
                try {
                  !i && s.return && s.return()
                } finally {
                  if (r) throw o
                }
              }
              return e
            }(t, n);
            throw new TypeError("Invalid attempt to destructure non-iterable instance")
          },
          e = function(t, n, e) {
            return n && r(t.prototype, n), e && r(t, e), t
          },
          e = (function(t, n) {
            if ("function" != typeof n && null !== n) throw new TypeError("Super expression must either be null or a function, not " + typeof n);
            t.prototype = Object.create(n && n.prototype, {
              constructor: {
                value: t,
                enumerable: !1,
                writable: !0,
                configurable: !0
              }
            }), n && (Object.setPrototypeOf ? Object.setPrototypeOf(t, n) : t.__proto__ = n)
          }(l, i.a), e(l, null, [{
            key: "fromASCIIGrid",
            value: function(t) {
              for (var n = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 1, e = t.split("\n"), i = l._parseASCIIGridHeader(e.slice(0, 6)), r = [], o = 6; o < e.length; o++) {
                var a = e[o].trim();
                if ("" === a) break;
                a.split(" ").forEach(function(t) {
                  t = parseFloat(t), t = t !== i.noDataValue ? t * n : null;
                  r.push(t)
                })
              }
              t = i;
              return t.zs = r, new l(t)
            }
          }, {
            key: "fromPNGGrid",
            value: function(t) {
              var n = {
                nCols: t.header.nx,
                nRows: t.header.ny,
                xllCorner: t.header.lo1,
                yllCorner: t.header.la2,
                cellXSize: t.header.dx,
                cellYSize: t.header.dy,
                noDataValue: 7e37
              };
              return n.zs = t.data, new l(n)
            }
          }, {
            key: "_parseASCIIGridHeader",
            value: function(t) {
              try {
                var n = t.map(function(t) {
                      var n, e = t.split(" ").filter(function(t) {
                        return "" != t
                      });
                      return n = {}, t = e[0].trim().toUpperCase(), e = parseFloat(e[1].trim()), t in n ? Object.defineProperty(n, t, {
                        value: e,
                        enumerable: !0,
                        configurable: !0,
                        writable: !0
                      }) : n[t] = e, n
                    }),
                    e = "XLLCORNER" in n[2],
                    i = n[4].CELLSIZE;
                return {
                  nCols: parseInt(n[0].NCOLS),
                  nRows: parseInt(n[1].NROWS),
                  xllCorner: e ? n[2].XLLCORNER : n[2].XLLCENTER - i,
                  yllCorner: e ? n[3].YLLCORNER : n[3].YLLCENTER - i,
                  cellXSize: i,
                  cellYSize: i,
                  noDataValue: n[5].NODATA_VALUE
                }
              } catch (t) {
                throw new Error("Not a valid ASCIIGrid Header: " + t)
              }
            }
          }, {
            key: "fromGeoTIFF",
            value: function(t) {
              return l.multipleFromGeoTIFF(t, [1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 0])[0]
            }
          }, {
            key: "multipleFromGeoTIFF",
            value: function(t, n) {
              var e = GeoTIFF.parse(t).getImage(),
                  i = e.readRasters(),
                  r = e.getTiePoints()[0],
                  o = e.getFileDirectory(),
                  t = u(o.ModelPixelScale, 2),
                  a = t[0],
                  s = t[1];
              return void 0 !== n && 0 !== n.length || (n = [].concat(function(t) {
                if (Array.isArray(t)) {
                  for (var n = 0, e = Array(t.length); n < t.length; n++) e[n] = t[n];
                  return e
                }
                return Array.from(t)
              }(Array(i.length).keys()))), n.map(function(t) {
                var n, t = i[t];
                return o.GDAL_NODATA && (n = parseFloat(o.GDAL_NODATA), t = Array.from(t).map(function(t) {
                  return t === n ? null : t
                })), new l({
                  nCols: e.getWidth(),
                  nRows: e.getHeight(),
                  xllCorner: r.x,
                  yllCorner: r.y - e.getHeight() * s,
                  cellXSize: a,
                  cellYSize: s,
                  zs: t
                })
              })
            }
          }]), e(l, [{
            key: "_buildGrid",
            value: function() {
              return this._arrayTo2d(this.zs, this.nRows, this.nCols)
            }
          }, {
            key: "_arrayTo2d",
            value: function(t, n, e) {
              for (var i = [], r = 0, o = 0; o < n; o++) {
                for (var a = [], s = 0; s < e; s++, r++) {
                  var u = t[r];
                  a[s] = this._isValid(u) ? u : null
                }
                i[o] = a
              }
              return i
            }
          }, {
            key: "_newDataArrays",
            value: function(t) {
              t.zs = []
            }
          }, {
            key: "_pushValueToArrays",
            value: function(t, n) {
              t.zs.push(n)
            }
          }, {
            key: "_makeNewFrom",
            value: function(t) {
              return new l(t)
            }
          }, {
            key: "_calculateRange",
            value: function() {
              var t = this.zs;
              return this._inFilter && (t = t.filter(this._inFilter))
            }
          }, {
            key: "_doInterpolation",
            value: function(t, n, e, i, r, o) {
              var a = 1 - t,
                  s = 1 - n;
              return e * a * s + i * t * s + r * a * n + o * t * n
            }
          }]), l);

      function l(t) {
        ! function(t) {
          if (!(t instanceof l)) throw new TypeError("Cannot call a class as a function")
        }(this);
        var n = function(t, n) {
          if (!t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
          return !n || "object" != typeof n && "function" != typeof n ? t : n
        }(this, (l.__proto__ || Object.getPrototypeOf(l)).call(this, t));
        return n.zs = t.zs, n.grid = n._buildGrid(), n._updateRange(), n
      }

      function r(t, n) {
        for (var e = 0; e < n.length; e++) {
          var i = n[e];
          i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
        }
      }
      n.a = e
    }, function(t, n, e) {
      var i = (function(t, n, e) {
        return n && o(t.prototype, n), e && o(t, e), t
      }(r, [{
        key: "magnitude",
        value: function() {
          return Math.sqrt(this.u * this.u + this.v * this.v)
        }
      }, {
        key: "directionTo",
        value: function() {
          var t = Math.atan2(this.u, this.v) * (180 / Math.PI);
          return t < 0 && (t += 360), t
        }
      }, {
        key: "directionFrom",
        value: function() {
          return (this.directionTo() + 180) % 360
        }
      }]), r);

      function r(t, n) {
        (function(t) {
          if (!(t instanceof r)) throw new TypeError("Cannot call a class as a function")
        })(this), this.u = t, this.v = n
      }

      function o(t, n) {
        for (var e = 0; e < n.length; e++) {
          var i = n[e];
          i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
        }
      }
      n.a = i
    }, function(t, n, e) {
      var f = e(3),
          i = e(1),
          r = e(2),
          o = function(t, n) {
            if (Array.isArray(t)) return t;
            if (Symbol.iterator in Object(t)) return function(t, n) {
              var e = [],
                  i = !0,
                  r = !1,
                  o = void 0;
              try {
                for (var a, s = t[Symbol.iterator](); !(i = (a = s.next()).done) && (e.push(a.value), !n || e.length !== n); i = !0);
              } catch (t) {
                r = !0, o = t
              } finally {
                try {
                  !i && s.return && s.return()
                } finally {
                  if (r) throw o
                }
              }
              return e
            }(t, n);
            throw new TypeError("Invalid attempt to destructure non-iterable instance")
          },
          e = function(t, n, e) {
            return n && s(t.prototype, n), e && s(t, e), t
          },
          e = (function(t, n) {
            if ("function" != typeof n && null !== n) throw new TypeError("Super expression must either be null or a function, not " + typeof n);
            t.prototype = Object.create(n && n.prototype, {
              constructor: {
                value: t,
                enumerable: !1,
                writable: !0,
                configurable: !0
              }
            }), n && (Object.setPrototypeOf ? Object.setPrototypeOf(t, n) : t.__proto__ = n)
          }(a, i.a), e(a, null, [{
            key: "fromASCIIGrids",
            value: function(t, n) {
              var e = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : 1,
                  t = r.a.fromASCIIGrid(t, e),
                  e = r.a.fromASCIIGrid(n, e);
              return new a(a._paramsFromScalarFields(t, e))
            }
          }, {
            key: "fromGeoTIFFs",
            value: function(t, n) {
              t = r.a.fromGeoTIFF(t), n = r.a.fromGeoTIFF(n);
              return new a(a._paramsFromScalarFields(t, n))
            }
          }, {
            key: "fromMultibandGeoTIFF",
            value: function(t) {
              var n = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : [0, 1],
                  t = r.a.multipleFromGeoTIFF(t, n),
                  n = o(t, 2),
                  t = n[0],
                  n = n[1];
              return new a(a._paramsFromScalarFields(t, n))
            }
          }, {
            key: "_paramsFromScalarFields",
            value: function(t, n) {
              return {
                nCols: t.nCols,
                nRows: t.nRows,
                xllCorner: t.xllCorner,
                yllCorner: t.yllCorner,
                cellXSize: t.cellXSize,
                cellYSize: t.cellYSize,
                us: t.zs,
                vs: n.zs
              }
            }
          }]), e(a, [{
            key: "getScalarField",
            value: function(t) {
              t = this._getFunctionFor(t), t = {
                nCols: this.params.nCols,
                nRows: this.params.nRows,
                xllCorner: this.params.xllCorner,
                yllCorner: this.params.yllCorner,
                cellXSize: this.params.cellXSize,
                cellYSize: this.params.cellYSize,
                zs: this._applyOnField(t)
              };
              return new r.a(t)
            }
          }, {
            key: "_getFunctionFor",
            value: function(e) {
              return function(t, n) {
                return new f.a(t, n)[e]()
              }
            }
          }, {
            key: "_applyOnField",
            value: function(t) {
              for (var n = [], e = this.numCells(), i = 0; i < e; i++) {
                var r = this.us[i],
                    o = this.vs[i];
                this._isValid(r) && this._isValid(o) ? n.push(t(r, o)) : n.push(null)
              }
              return n
            }
          }, {
            key: "_buildGrid",
            value: function() {
              return this._arraysTo2d(this.us, this.vs, this.nRows, this.nCols)
            }
          }, {
            key: "_arraysTo2d",
            value: function(t, n, e, i) {
              for (var r = [], o = 0, a = 0; a < e; a++) {
                for (var s = [], u = 0; u < i; u++, o++) {
                  var l = t[o],
                      h = n[o],
                      c = this._isValid(l) && this._isValid(h);
                  s[u] = c ? new f.a(l, h) : null
                }
                r[a] = s
              }
              return r
            }
          }, {
            key: "_newDataArrays",
            value: function(t) {
              t.us = [], t.vs = []
            }
          }, {
            key: "_pushValueToArrays",
            value: function(t, n) {
              t.us.push(n.u), t.vs.push(n.v)
            }
          }, {
            key: "_makeNewFrom",
            value: function(t) {
              return new a(t)
            }
          }, {
            key: "_calculateRange",
            value: function() {
              var t = this.getCells().map(function(t) {
                return t.value
              }).filter(function(t) {
                return null !== t
              });
              this._inFilter && (t = t.filter(this._inFilter));
              t = t.map(function(t) {
                return t.magnitude()
              });
              return [d3.min(t), d3.max(t)]
            }
          }, {
            key: "_doInterpolation",
            value: function(t, n, e, i, r, o) {
              var a = 1 - t,
                  s = 1 - n,
                  u = a * s,
                  s = t * s,
                  a = a * n,
                  t = t * n,
                  n = e.u * u + i.u * s + r.u * a + o.u * t,
                  t = e.v * u + i.v * s + r.v * a + o.v * t;
              return new f.a(n, t)
            }
          }, {
            key: "_isValid",
            value: function(t) {
              return null != t
            }
          }]), a);

      function a(t) {
        ! function(t) {
          if (!(t instanceof a)) throw new TypeError("Cannot call a class as a function")
        }(this);
        var n = function(t, n) {
          if (!t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
          return !n || "object" != typeof n && "function" != typeof n ? t : n
        }(this, (a.__proto__ || Object.getPrototypeOf(a)).call(this, t));
        return n.us = t.us, n.vs = t.vs, n.grid = n._buildGrid(), n.range = n._calculateRange(), n
      }

      function s(t, n) {
        for (var e = 0; e < n.length; e++) {
          var i = n[e];
          i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
        }
      }
      n.a = e
    }, function(t, n) {
      var r = function(t, n) {
        if (Array.isArray(t)) return t;
        if (Symbol.iterator in Object(t)) return function(t, n) {
          var e = [],
              i = !0,
              r = !1,
              o = void 0;
          try {
            for (var a, s = t[Symbol.iterator](); !(i = (a = s.next()).done) && (e.push(a.value), !n || e.length !== n); i = !0);
          } catch (t) {
            r = !0, o = t
          } finally {
            try {
              !i && s.return && s.return()
            } finally {
              if (r) throw o
            }
          }
          return e
        }(t, n);
        throw new TypeError("Invalid attempt to destructure non-iterable instance")
      };
      L.Control.ColorBar = L.Control.extend({
        options: {
          position: "bottomleft",
          width: 300,
          height: 15,
          margin: 15,
          background: "#fff",
          textColor: "black",
          steps: 100,
          decimals: 2,
          units: "uds",
          title: "Legend",
          labels: [],
          labelFontSize: 10,
          cb: null,
          index: 0,
          labelTextPosition: "middle"
        },
        initialize: function(t, n, e) {
          this.color = t, this.range = n, L.Util.setOptions(this, e), console.log(this.options.index), d3.select(this.colorBar).attr("data-index", this.options.index), this.colorBar && (this.unit = this._createUnitToggle(this.colorBar))
        },
        onAdd: function(t) {
          this._map = t;
          t = L.DomUtil.create("div", "leaflet-control-colorBar leaflet-bar leaflet-control");
          return (this.colorBar = t).style.padding = "10px", L.DomEvent.addListener(t, "click", L.DomEvent.stopPropagation).addListener(t, "click", L.DomEvent.preventDefault), t.style.backgroundColor = this.options.background, t.style.cursor = "text", this.unit = this._createUnitToggle(t), t.innerHTML = this.title() + this.palette(), L.DomEvent.addListener(t, "click", this._nextUnit, this), t
        },
        title: function() {
          var t = document.createElement("div"),
              n = "";
          return "" !== this.unit.value().label && (n = "(" + this.unit.value().label + ")"), d3.select(t).append("span").style("color", this.options.textColor).style("display", "block").style("margin-bottom", "5px").attr("class", "leaflet-control-colorBar-title").text(this.options.title + n), t.innerHTML
        },
        palette: function() {
          var t = document.createElement("div"),
              n = this._createSvgIn(t),
              e = this._createUlIn(t);
          return this._appendColorBarTo(n), this.options.labels && (this._appendLabelsTo(n), this._appendPhoneColorBarTo(e)), t.innerHTML
        },
        _appendPhoneColorBarTo: function(e) {
          var i = this,
              r = this.options.phoneColoe;
          this.options.labels.forEach(function(t, n) {
            t = i.unit.value().conversion(t);
            !i.unit.value().precision && 0 !== i.unit.value().precision || (t = t.toFixed(i.unit.value().precision)), e.insert("li", ".phone-color-li:nth-child(1)").attr("class", "phone-color-li text-center").text(t).style("color", "white").style("background-color", "rgb(" + r[n][0] + "," + r[n][1] + "," + r[n][2] + ")")
          }), e.style("display", "none")
        },
        _createUlIn: function(t) {
          return d3.select(t).append("ul").attr("id", "phone_ul_color_bar").style("width", "50px").attr("class", "leaflet-control-colorBar")
        },
        _createSvgIn: function(t) {
          var n = this.options.labels ? this.options.margin : 0;
          return d3.select(t).append("svg").attr("id", "pc_svg_color_bar").attr("width", this.options.width + 2 * this.options.margin).attr("height", this.options.height + n)
        },
        _appendColorBarTo: function(t) {
          var e = this,
              n = this._getColorPerValue(),
              i = this.options.width / n.length,
              n = t.append("g").attr("id", "colorBar-buckets").selectAll("rect").data(n).enter().append("rect");
          n.attr("x", function(t, n) {
            return n * i + e.options.margin
          }).attr("y", function() {
            return 0
          }).attr("height", function() {
            return e.options.height
          }).attr("width", function() {
            return i
          }).attr("stroke-width", 2).attr("stroke-linecap", "butt").attr("stroke", function(t) {
            return t.color.hex()
          }).attr("fill", function(t) {
            return t.color.hex()
          }), n.append("title").text(function(t) {
            return e.unit.value().conversion(t.value).toFixed(e.unit.value().precision) + " " + e.unit.value().label
          })
        },
        _appendLabelsTo: function(t) {
          var n = this,
              e = this._getPositionPerLabelValue();
          t.append("g").attr("id", "colorBar-labels").selectAll("text").data(e).enter().append("text").attr("x", function(t) {
            return t.position + n.options.margin
          }).attr("y", this.options.height + this.options.margin).attr("font-size", this.options.labelFontSize + "px").attr("text-anchor", this.options.labelTextPosition).attr("fill", this.options.textColor).attr("class", "leaflet-control-colorBar-label").text(function(t) {
            return "" + n.unit.value().conversion(t.value).toFixed(n.unit.value().precision)
          })
        },
        _getColorPerValue: function() {
          var n = this,
              t = r(this.range, 2),
              e = t[0],
              i = t[1],
              t = (i - e) / this.options.steps;
          return d3.range(e, i + t, t).map(function(t) {
            return {
              value: t,
              color: n.color(t)
            }
          })
        },
        _getPositionPerLabelValue: function() {
          var n = d3.scaleLinear().range([0, this.options.width]).domain(this.range);
          return this.options.labels.map(function(t) {
            return {
              value: t,
              position: n(t)
            }
          })
        },
        _createUnitToggle: function(t) {
          var n = this.options.units,
              e = n.length,
              i = +(d3.select(t).attr("data-index") || 0) % e;
          return {
            value: function() {
              return n[i]
            },
            next: function() {
              d3.select(t).attr("data-index", i = (i + 1) % e)
            }
          }
        },
        _nextUnit: function() {
          this.unit.next(), this.colorBar.innerHTML = this.title() + this.palette(), this.options.cb && this.options.cb()
        },
        show: function() {
          this.colorBar.innerHTML = this.title() + this.palette()
        }
      }), L.control.colorBar = function(t, n, e) {
        return new L.Control.ColorBar(t, n, e)
      }
    }, function(t, n) {
      L.CanvasLayer.Field = L.CanvasLayer.extend({
        options: {
          mouseMoveCursor: {
            value: "pointer",
            noValue: "default"
          },
          opacity: 1,
          onClick: null,
          onMouseMove: null,
          inFilter: null
        },
        initialize: function(t, n) {
          L.Util.setOptions(this, n), this._visible = !0, t && this.setData(t)
        },
        getEvents: function() {
          var t = L.CanvasLayer.prototype.getEvents.call(this);
          return t.zoomstart = this._hideCanvas.bind(this), t.zoomend = this._showCanvas.bind(this), t
        },
        onLayerDidMount: function() {
          this._enableIdentify(), this._ensureCanvasAlignment()
        },
        show: function() {
          this._visible = !0, this._showCanvas(), this._enableIdentify()
        },
        hide: function() {
          this._visible = !1, this._hideCanvas(), this._disableIdentify()
        },
        isVisible: function() {
          return this._visible
        },
        _showCanvas: function() {
          this._canvas && this._visible && (this._canvas.style.visibility = "visible")
        },
        _hideCanvas: function() {
          this._canvas && (this._canvas.style.visibility = "hidden")
        },
        _enableIdentify: function() {
          this._map.on("click", this._onClick, this), this._map.on("mousemove", this._onMouseMove, this), this.options.onClick && this.on("click", this.options.onClick, this), this.options.onMouseMove && this.on("mousemove", this.options.onMouseMove, this)
        },
        _disableIdentify: function() {
          this._map.off("click", this._onClick, this), this._map.off("mousemove", this._onMouseMove, this), this.options.onClick && this.off("click", this.options.onClick, this), this.options.onMouseMove && this.off("mousemove", this.options.onMouseMove, this)
        },
        _ensureCanvasAlignment: function() {
          var t = this._map.containerPointToLayerPoint([0, 0]);
          L.DomUtil.setPosition(this._canvas, t)
        },
        onLayerWillUnmount: function() {
          this._disableIdentify()
        },
        needRedraw: function() {
          this._map && this._field && L.CanvasLayer.prototype.needRedraw.call(this)
        },
        onDrawLayer: function(t) {
          throw new TypeError("Must be overriden")
        },
        setData: function(t) {
          this.options.inFilter && t.setFilter(this.options.inFilter), this._field = t, this.needRedraw(), this.fire("load")
        },
        setFilter: function(t) {
          this.options.inFilter = t, this._field && this._field.setFilter(t), this.needRedraw()
        },
        setOpacity: function(t) {
          return this.options.opacity = t, this._canvas && this._updateOpacity(), this
        },
        getBounds: function() {
          var t = this._field.extent(),
              n = L.latLng(t[1], t[0]),
              t = L.latLng(t[3], t[2]);
          return L.latLngBounds(n, t)
        },
        _onClick: function(t) {
          t = this._queryValue(t);
          this.fire("click", t)
        },
        _onMouseMove: function(t) {
          t = this._queryValue(t);
          this._changeCursorOn(t), this.fire("mousemove", t)
        },
        _changeCursorOn: function(t) {
          var n, e;
          this.options.mouseMoveCursor && (n = (e = this.options.mouseMoveCursor).value, e = e.noValue, this._map.getContainer().style.cursor = null !== t.value ? n : e)
        },
        _updateOpacity: function() {
          L.DomUtil.setOpacity(this._canvas, this.options.opacity)
        },
        _queryValue: function(t) {
          var n = this._field ? this._field.valueAt(t.latlng.lng, t.latlng.lat) : null;
          return {
            latlng: t.latlng,
            value: n
          }
        },
        _getDrawingContext: function() {
          var t = this._canvas.getContext("2d");
          return t.clearRect(0, 0, this._canvas.width, this._canvas.height), t
        }
      })
    }, function(t, n, e) {
      Object.defineProperty(n, "__esModule", {
        value: !0
      });
      var l = e(0),
          c = function(t, n) {
            if (Array.isArray(t)) return t;
            if (Symbol.iterator in Object(t)) return function(t, n) {
              var e = [],
                  i = !0,
                  r = !1,
                  o = void 0;
              try {
                for (var a, s = t[Symbol.iterator](); !(i = (a = s.next()).done) && (e.push(a.value), !n || e.length !== n); i = !0);
              } catch (t) {
                r = !0, o = t
              } finally {
                try {
                  !i && s.return && s.return()
                } finally {
                  if (r) throw o
                }
              }
              return e
            }(t, n);
            throw new TypeError("Invalid attempt to destructure non-iterable instance")
          };
      L.CanvasLayer.ScalarField = L.CanvasLayer.Field.extend({
        options: {
          type: "colormap",
          color: null,
          interpolate: !1,
          vectorSize: 20,
          arrowDirection: "from"
        },
        initialize: function(t, n) {
          L.CanvasLayer.Field.prototype.initialize.call(this, t, n), L.Util.setOptions(this, n)
        },
        _defaultColorScale: function() {
          return chroma.scale(["white", "black"]).domain(this._field.range)
        },
        setColor: function(t) {
          this.options.color = t, this.needRedraw()
        },
        onDrawLayer: function(t) {
          this.isVisible() && (this._updateOpacity(), this._getRendererMethod()())
        },
        _getRendererMethod: function() {
          switch (this.options.type) {
            case "colormap":
              return this._drawImage.bind(this);
            case "vector":
              return this._drawArrows.bind(this);
            default:
              throw Error("Unkwown renderer type: " + this.options.type)
          }
        },
        _ensureColor: function() {
          null === this.options.color && this.setColor(this._defaultColorScale())
        },
        _showCanvas: function() {
          L.CanvasLayer.Field.prototype._showCanvas.call(this), this.needRedraw()
        },
        _drawImage: function() {
          this._ensureColor();
          var t = this._getDrawingContext(),
              n = this._canvas.width,
              e = this._canvas.height,
              i = t.createImageData(n, e),
              r = i.data;
          this._prepareImageIn(r, n, e), t.putImageData(i, 0, 0)
        },
        deg2rad: function(t) {
          return t / 180 * Math.PI
        },
        rad2deg: function(t) {
          return t / (Math.PI / 180)
        },
        _invert: function(t, n, e) {
          var i = e.east - e.west,
              r = e.width / this.rad2deg(i) * 360 / (2 * Math.PI),
              o = r / 2 * Math.log((1 + Math.sin(e.south)) / (1 - Math.sin(e.south))),
              r = (e.height + o - n) / r,
              r = 180 / Math.PI * (2 * Math.atan(Math.exp(r)) - Math.PI / 2);
          return {
            lng: this.rad2deg(e.west) + t / e.width * this.rad2deg(i),
            lat: r
          }
        },
        _prepareImageIn: function(t, n, e) {
          for (var i = this.options.interpolate ? "interpolatedValueAt" : "valueAt", r = 0, o = 0; o < e; o += 2) {
            for (var a = 0; a < n; a += 2) {
              var s = this._map.containerPointToLatLng([a, o]),
                  u = s.lng,
                  l = s.lat,
                  h = this._field[i](u, l);
              null !== h && (s = this._getColorFor(h).rgba(), l = (u = c(s, 4))[0], h = u[1], s = u[2], u = u[3], t[r] = l, t[r + 1] = h, t[r + 2] = s, t[r + 3] = parseInt(255 * u), t[r + 4] = l, t[r + 4 + 1] = h, t[r + 4 + 2] = s, t[r + 4 + 3] = parseInt(255 * u), t[r + 4 * n] = l, t[r + 4 * n + 1] = h, t[r + 4 * n + 2] = s, t[r + 4 * n + 3] = parseInt(255 * u), t[r + 4 * n + 4] = l, t[r + 4 * n + 4 + 1] = h, t[r + 4 * n + 4 + 2] = s, t[r + 4 * n + 4 + 3] = parseInt(255 * u)), r += 8
            }
            r += 4 * (n - (n % 2 != 0 ? 1 : 0))
          }
        },
        _drawArrows: function() {
          var t = this._pixelBounds(),
              t = (t.max.x - t.min.x) / this._field.nCols,
              n = Math.max(1, Math.floor(1.2 * this.options.vectorSize / t)),
              e = this._getDrawingContext();
          e.strokeStyle = this.options.color;
          for (var i = this._map.getBounds(), r = 0; r < this._field.height; r += n)
            for (var o = 0; o < this._field.width; o += n) {
              var a = this._field._lonLatAtIndexes(o, r),
                  s = c(a, 2),
                  u = s[0],
                  a = s[1],
                  s = this._field.valueAt(u, a),
                  u = L.latLng(a, u);
              null !== s && i.contains(u) && (s = new l.a(u, s, this.cellXSize, this.cellYSize), this._drawArrow(s, e))
            }
        },
        _pixelBounds: function() {
          var t = this.getBounds(),
              n = this._map.latLngToContainerPoint(t.getNorthWest()),
              t = this._map.latLngToContainerPoint(t.getSouthEast());
          return L.bounds(n, t)
        },
        _drawArrow: function(t, n) {
          var e = this._map.latLngToContainerPoint(t.center),
              i = this.options.color;
          "function" == typeof i && (n.strokeStyle = i(t.value));
          i = this.options.vectorSize;
          n.save(), n.translate(e.x, e.y);
          t = (90 + t.value) * Math.PI / 180;
          "towards" === this.options.arrowDirection && (t += Math.PI), n.rotate(t), n.beginPath(), n.moveTo(-i / 2, 0), n.lineTo(+i / 2, 0), n.moveTo(.25 * i, .25 * -i), n.lineTo(+i / 2, 0), n.lineTo(.25 * i, .25 * i), n.stroke(), n.restore()
        },
        _getColorFor: function(t) {
          return this.options.color(t)
        }
      }), L.canvasLayer.scalarField = function(t, n) {
        return new L.CanvasLayer.ScalarField(t, n)
      }
    }, function(t, n) {
      function r(t) {
        if (Array.isArray(t)) {
          for (var n = 0, e = Array(t.length); n < t.length; n++) e[n] = t[n];
          return e
        }
        return Array.from(t)
      }
      L.CanvasLayer.SimpleLonLat = L.CanvasLayer.extend({
        options: {
          color: "gray"
        },
        initialize: function(t, n) {
          this.points = t, L.Util.setOptions(this, n)
        },
        onLayerDidMount: function() {},
        onLayerWillUnmount: function() {},
        setData: function(t) {
          this.needRedraw()
        },
        onDrawLayer: function(t) {
          var n = t.canvas.getContext("2d");
          n.clearRect(0, 0, t.canvas.width, t.canvas.height), n.fillStyle = this.options.color;
          var e = !0,
              i = !1,
              r = void 0;
          try {
            for (var o = this.points[Symbol.iterator](); !(e = (a = o.next()).done); e = !0) {
              var a = a.value,
                  a = t.layer._map.latLngToContainerPoint(a);
              n.beginPath(), n.fillRect(a.x, a.y, 2, 2), n.fill(), n.closePath(), n.stroke()
            }
          } catch (t) {
            i = !0, r = t
          } finally {
            try {
              !e && o.return && o.return()
            } finally {
              if (i) throw r
            }
          }
        },
        getBounds: function() {
          var t = this.points.map(function(t) {
                return t.lng
              }),
              n = this.points.map(function(t) {
                return t.lat
              }),
              e = Math.min.apply(Math, r(t)),
              i = Math.min.apply(Math, r(n)),
              t = Math.max.apply(Math, r(t)),
              n = Math.max.apply(Math, r(n)),
              e = L.latLng(i, e),
              t = L.latLng(n, t);
          return L.latLngBounds(e, t)
        }
      }), L.canvasLayer.simpleLonLat = function(t, n) {
        return new L.CanvasLayer.SimpleLonLat(t, n)
      }
    }, function(t, n) {
      L.CanvasLayer.VectorFieldAnim = L.CanvasLayer.Field.extend({
        options: {
          paths: 800,
          color: "white",
          width: 1,
          fade: .96,
          duration: 20,
          maxAge: 200,
          velocityScale: 2e-4
        },
        initialize: function(t, n) {
          L.CanvasLayer.Field.prototype.initialize.call(this, t, n), L.Util.setOptions(this, n), this.timer = null
        },
        onLayerDidMount: function() {
          L.CanvasLayer.Field.prototype.onLayerDidMount.call(this), this._map.on("move resize", this._stopAnimation, this)
        },
        onLayerWillUnmount: function() {
          L.CanvasLayer.Field.prototype.onLayerWillUnmount.call(this), this._map.off("move resize", this._stopAnimation, this), this._stopAnimation()
        },
        _hideCanvas: function() {
          L.CanvasLayer.Field.prototype._hideCanvas.call(this), this._stopAnimation()
        },
        onDrawLayer: function(n) {
          var e, i, r;
          this._field && this.isVisible() && (this._updateOpacity(), e = this._getDrawingContext(), i = this._prepareParticlePaths(), this.timer = d3.timer(function() {
            var t;
            i.forEach(function(t) {
              t.age > r.options.maxAge && (t.age = 0, r._field.randomPosition(t));
              var n, e, i = r._field.valueAt(t.x, t.y);
              null === i ? t.age = r.options.maxAge : (n = t.x + i.u * r.options.velocityScale, e = t.y + i.v * r.options.velocityScale, r._field.hasValueAt(n, e) ? (t.xt = n, t.yt = e, t.m = i.magnitude()) : t.age = r.options.maxAge), t.age += 1
            }), t = e.globalCompositeOperation, e.globalCompositeOperation = "destination-in", e.fillRect(0, 0, e.canvas.width, e.canvas.height), e.globalCompositeOperation = t, e.fillStyle = "rgba(0, 0, 0, " + r.options.fade + ")", e.lineWidth = r.options.width, e.strokeStyle = r.options.color, i.forEach(function(t) {
              r._drawParticle(n, e, t)
            })
          }, this.options.duration), r = this)
        },
        _drawParticle: function(t, n, e) {
          var i = new L.latLng(e.y, e.x),
              r = new L.latLng(e.yt, e.xt);
          t.bounds.contains(i) && e.age <= this.options.maxAge && (i = t.layer._map.latLngToContainerPoint(i), r = t.layer._map.latLngToContainerPoint(r), n.beginPath(), n.moveTo(i.x, i.y), n.lineTo(r.x, r.y), e.x = e.xt, e.y = e.yt, "function" == typeof(r = this.options.color) && (n.strokeStyle = r(e.m)), "function" == typeof(r = this.options.width) && (n.lineWidth = r(e.m)), n.stroke())
        },
        _prepareParticlePaths: function() {
          for (var t = [], n = 0; n < this.options.paths; n++) {
            var e = this._field.randomPosition();
            e.age = this._randomAge(), t.push(e)
          }
          return t
        },
        _randomAge: function() {
          return Math.floor(Math.random() * this.options.maxAge)
        },
        _stopAnimation: function() {
          this.timer && this.timer.stop()
        }
      }), L.canvasLayer.vectorFieldAnim = function(t, n) {
        return new L.CanvasLayer.VectorFieldAnim(t, n)
      }
    }, function(t, n) {
      L.CanvasLayer = L.Layer.extend({
        initialize: function(t) {
          this._map = null, this._canvas = null, this._frame = null, this._delegate = null, L.setOptions(this, t)
        },
        delegate: function(t) {
          return this._delegate = t, this
        },
        needRedraw: function() {
          return this._frame || (this._frame = L.Util.requestAnimFrame(this.drawLayer, this)), this
        },
        _onLayerDidResize: function(t) {
          this._canvas.width = t.newSize.x, this._canvas.height = t.newSize.y
        },
        _onLayerDidMove: function() {
          var t = this._map.containerPointToLayerPoint([0, 0]);
          L.DomUtil.setPosition(this._canvas, t), this.drawLayer()
        },
        getEvents: function() {
          var t = {
            resize: this._onLayerDidResize,
            moveend: this._onLayerDidMove
          };
          return this._map.options.zoomAnimation && L.Browser.any3d && (t.zoomanim = this._animateZoom), t
        },
        onAdd: function(t) {
          this._map = t, this._canvas = L.DomUtil.create("canvas", "leaflet-layer"), this.tiles = {};
          var n = this._map.getSize();
          this._canvas.width = n.x, this._canvas.height = n.y;
          n = this._map.options.zoomAnimation && L.Browser.any3d;
          L.DomUtil.addClass(this._canvas, "leaflet-zoom-" + (n ? "animated" : "hide")), t._panes.overlayPane.appendChild(this._canvas), t.on(this.getEvents(), this);
          t = this._delegate || this;
          t.onLayerDidMount && t.onLayerDidMount(), this.needRedraw();
          var e = this;
          setTimeout(function() {
            e._onLayerDidMove()
          }, 0)
        },
        onRemove: function(t) {
          var n = this._delegate || this;
          n.onLayerWillUnmount && n.onLayerWillUnmount(), t.getPanes().overlayPane.removeChild(this._canvas), t.off(this.getEvents(), this), this._canvas = null
        },
        addTo: function(t) {
          return t.addLayer(this), this
        },
        LatLonToMercator: function(t) {
          return {
            x: 6378137 * t.lng * Math.PI / 180,
            y: 6378137 * Math.log(Math.tan((90 + t.lat) * Math.PI / 360))
          }
        },
        drawLayer: function() {
          var t = this._map.getSize(),
              n = this._map.getBounds(),
              e = this._map.getZoom(),
              i = this.LatLonToMercator(this._map.getCenter()),
              r = this.LatLonToMercator(this._map.containerPointToLatLng(this._map.getSize())),
              o = this._delegate || this;
          o.onDrawLayer && o.onDrawLayer({
            layer: this,
            canvas: this._canvas,
            bounds: n,
            size: t,
            zoom: e,
            center: i,
            corner: r
          }), this._frame = null
        },
        _setTransform: function(t, n, e) {
          n = n || new L.Point(0, 0);
          t.style[L.DomUtil.TRANSFORM] = (L.Browser.ie3d ? "translate(" + n.x + "px," + n.y + "px)" : "translate3d(" + n.x + "px," + n.y + "px,0)") + (e ? " scale(" + e + ")" : "")
        },
        _animateZoom: function(t) {
          var n = this._map.getZoomScale(t.zoom),
              t = this._map._latLngToNewLayerPoint(this._map.getBounds().getNorthWest(), t.zoom, t.center);
          L.DomUtil.setTransform(this._canvas, t, n)
        }
      }), L.canvasLayer = function() {
        return new L.CanvasLayer
      }
    }, function(t, n, e) {
      function h(t, n, e) {
        var i = !1;
        n[0][0] === n[n.length - 1][0] && n[0][1] === n[n.length - 1][1] && (n = n.slice(0, n.length - 1));
        for (var r = 0, o = n.length - 1; r < n.length; o = r++) {
          var a = n[r][0],
              s = n[r][1],
              u = n[o][0],
              l = n[o][1];
          if (t[1] * (a - u) + s * (u - t[0]) + l * (t[0] - a) == 0 && (a - t[0]) * (u - t[0]) <= 0 && (s - t[1]) * (l - t[1]) <= 0) return !e;
          s > t[1] != l > t[1] && t[0] < (u - a) * (t[1] - s) / (l - s) + a && (i = !i)
        }
        return i
      }
      var e = e(12),
          c = e.getCoord,
          f = e.getCoords;
      t.exports = function(t, n, e) {
        if (!t) throw new Error("point is required");
        if (!n) throw new Error("polygon is required");
        var i = c(t),
            r = f(n),
            o = (n.geometry || n).type,
            t = n.bbox;
        if (t && !1 == (n = i, (t = t)[0] <= n[0] && t[1] <= n[1] && t[2] >= n[0] && t[3] >= n[1])) return !1;
        "Polygon" === o && (r = [r]);
        for (var a = 0, s = !1; a < r.length && !s; a++)
          if (h(i, r[a][0], e)) {
            for (var u = !1, l = 1; l < r[a].length && !u;) h(i, r[a][l], !e) && (u = !0), l++;
            u || (s = !0)
          } return s
      }
    }, function(t, n) {
      function e(t) {
        if (!t) throw new Error("obj is required");
        var n;
        if (t.length ? n = t : t.coordinates ? n = t.coordinates : t.geometry && t.geometry.coordinates && (n = t.geometry.coordinates), n) return i(n), n;
        throw new Error("No valid coordinates")
      }

      function i(t) {
        if (1 < t.length && "number" == typeof t[0] && "number" == typeof t[1]) return !0;
        if (Array.isArray(t[0]) && t[0].length) return i(t[0]);
        throw new Error("coordinates must only contain numbers")
      }

      function r(t) {
        if (!t) throw new Error("geojson is required");
        if (void 0 !== t.geometry) return t.geometry;
        if (t.coordinates || t.geometries) return t;
        throw new Error("geojson must be a valid Feature or Geometry Object")
      }
      t.exports = {
        geojsonType: function(t, n, e) {
          if (!n || !e) throw new Error("type and name required");
          if (!t || t.type !== n) throw new Error("Invalid input to " + e + ": must be a " + n + ", given " + t.type)
        },
        collectionOf: function(t, n, e) {
          if (!t) throw new Error("No featureCollection passed");
          if (!e) throw new Error(".collectionOf() requires a name");
          if (!t || "FeatureCollection" !== t.type) throw new Error("Invalid input to " + e + ", FeatureCollection required");
          for (var i = 0; i < t.features.length; i++) {
            var r = t.features[i];
            if (!r || "Feature" !== r.type || !r.geometry) throw new Error("Invalid input to " + e + ", Feature with geometry required");
            if (!r.geometry || r.geometry.type !== n) throw new Error("Invalid input to " + e + ": must be a " + n + ", given " + r.geometry.type)
          }
        },
        featureOf: function(t, n, e) {
          if (!t) throw new Error("No feature passed");
          if (!e) throw new Error(".featureOf() requires a name");
          if (!t || "Feature" !== t.type || !t.geometry) throw new Error("Invalid input to " + e + ", Feature with geometry required");
          if (!t.geometry || t.geometry.type !== n) throw new Error("Invalid input to " + e + ": must be a " + n + ", given " + t.geometry.type)
        },
        getCoord: function(t) {
          if (!t) throw new Error("obj is required");
          if (1 < (t = e(t)).length && "number" == typeof t[0] && "number" == typeof t[1]) return t;
          throw new Error("Coordinate is not a valid Point")
        },
        getCoords: e,
        containsNumber: i,
        getGeom: r,
        getGeomType: function(t) {
          if (!t) throw new Error("geojson is required");
          if (t = r(t)) return t.type
        }
      }
    }, function(t, n, e) {
      Object.defineProperty(n, "__esModule", {
        value: !0
      });
      var i = e(3),
          r = e(0),
          o = e(1),
          a = e(2),
          n = e(4);
      window.L.Vector = i.a, window.L.Cell = r.a, window.L.Field = o.a, window.L.ScalarField = a.a, window.L.VectorField = n.a, e(10), e(8), e(6), e(7), e(9), e(5), console.log("leaflet.canvaslayer.field v1.4.1")
    }])